`
xitong
  • 浏览: 6197238 次
文章分类
社区版块
存档分类
最新评论

sybase的SQL去掉字段中数据的空格(前空格、后空格、所有空格)

 
阅读更多

摘要:我们在使用sybase数据库的时候经常会遇到字段中出现不同位置的空格,如字段值前空格“ sdfsd”,字段值中间出现空格“sdfsdf dsfsd”,字段值后面出现空格“sfsdfs ”,当我们遇到这样的问题,我们怎么快速的去除所有的空格;

1、查询结果去掉左空格

select ltrim(字段) from xxxx where id=278

2、查询结果去掉右空格

select rtrim(字段) from xxxx where id=278

3、查询结果去掉所有的空格

select str_replace(字段,' ',null) from xxxx where id=278

4、更新到sybase数据库去掉左空格

update xxxx set 字段=(
select ltrim(字段) from xxxx where id=278

) where id=278

5、更新到sybase数据库去掉右空格

update xxxx set 字段=(
select rtrim(字段) from xxxx where id=278

) where id=278

6、更新到sybase数据库去掉所有的空格

update xxxx set 字段=(

select str_replace(字段,' ',null) from xxxx where id=278

) where id=278



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics