如何查询非空的行

kvkensinb 2010-10-19 04:54:44
sql通常都是查列非空的,有没办法查行非空的?谢谢
...全文
299 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
abuying 2010-10-20
  • 打赏
  • 举报
回复
--自身左连接 ,查询 is null记录。

select a.* from tb a left join tb b on a.[col1]=b.[col1] where b.[col1] is null
ask_chang 2010-10-20
  • 打赏
  • 举报
回复
笨方法:

一列一列判断非空
claro 2010-10-19
  • 打赏
  • 举报
回复
set ansi_null off

select * from tb where col1 <> null and col2 <> null .....


set ansi_null on

select * from tb where col1 is not null and col2 is not null .....
dawugui 2010-10-19
  • 打赏
  • 举报
回复
[Quote=引用楼主 kvkensinb 的回复:]
sql通常都是查列非空的,有没办法查行非空的?谢谢
[/Quote]
select * from tb where col1 is not null and col2 is not null .....
黄_瓜 2010-10-19
  • 打赏
  • 举报
回复
行非空呀


where cast(col as sql_variant)
+cast(co2 as sql_variant)
+cast(co3 as sql_variant)
is not null

这样??
jiao3630 2010-10-19
  • 打赏
  • 举报
回复
3貌似应该是

where col is not null and col !=''

王向飞 2010-10-19
  • 打赏
  • 举报
回复
col1 is not null and col2 is not null and col3 is not null
chuifengde 2010-10-19
  • 打赏
  • 举报
回复
1.把行变成列,查非空列
2.用函数判断行的结果再作为查询条件
jiao3630 2010-10-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 beirut 的回复:]
SQL code
--1
where col is not null
--2
where col !=''
--3
where col is not null and col !-''
[/Quote]
+1
黄_瓜 2010-10-19
  • 打赏
  • 举报
回复
--1
where col is not null
--2
where col !=''
--3
where col is not null and col !-''

22,300

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧