sql 如何查询 空值的字段?
2022-12-14 · 百度认证:北京惠企网络技术有限公司官方账号
sql查询空值的字段写法:SELECT A.字段 FROM student A WHERE A.字段 LIKE'% %' (student为表名)
查询类似空值的写法:
1、查询名称有退格键:select * from t_bd_item_info where charindex(char(8),item_name) > 0 go
2、查询名称有制表符tab:select * from t_bd_item_info where charindex(char(9),item_name) > 0 go
3、查询名称有换行:select * from t_bd_item_info where charindex(char(10),item_name) > 0 go
4、查询名称有回车:select * from t_bd_item_info where charindex(char(13),item_name) > 0 go
5、查询名称的空格(前空格、后空格、所有空格):select * from t_bd_item_info where isnull(charindex(' ',item_name),0) > 0 go
6、查询名称的单引号:select * from t_bd_item_info where charindex(char(39),item_name) > 0 go
7、查询名称的双单引号:select * from t_bd_item_info where charindex(char(34),item_name) > 0 go
扩展资料
1、处理名称有退格键
update t_bd_item_info set item_name = replace(item_name,char(8),'')
where charindex(char(9),item_name) > 0 go
2、处理名称有制表符tab
update t_bd_item_info set item_name = replace(item_name,char(9),'')
where charindex(char(9),item_name) > 0 go
3、处理名称有换行
update t_bd_item_info set item_name = replace(item_name,char(10),'')
where charindex(char(10),item_name) > 0 go
4、处理名称有回车
update t_bd_item_info set item_name = replace(item_name,char(13),'')
where charindex(char(13),item_name) > 0 go
5、处理名称的空格(前空格、后空格、所有空格)
update t_bd_item_info set item_name = replace(rtrim(ltrim(item_name)),' ','')
where isnull(charindex(' ',item_name),0) > 0 go
6、处理名称的单引号
update t_bd_item_info set item_name = replace(item_name,char(39),'')
where charindex(char(39),item_name) > 0 go
7、处理名称的双单引号
update t_bd_item_info set item_name = replace(item_name,char(34),'')
where charindex(char(34),item_name) > 0 go
参考资料:百度百科-结构化查询语言(SQL)
广告 您可能关注的内容 |