摘要:我们在使用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
本文介绍了在Sybase数据库中如何有效地去除字段值中的空格,包括查询时去除左右及所有空格的方法,并提供了更新数据库时去除空格的具体SQL语句。
2623

被折叠的 条评论
为什么被折叠?



