注册 登录
编程论坛 SQL Server论坛

求教大虾,sql查询,只输出值不空的

yellowray 发布于 2008-09-16 08:55, 2678 次点击
有个表"A"里面有.name,address,phone,
..
条件是这样的
只输出 这3项都有值的数据,,,因为.有些没name 或者address,或phone

怎么才能只输出.3项都有值的数据??
大虾们..求教了.
12 回复
#2
seiya0278482008-09-16 09:17
通过添加where 条件就行了,比如where name<>'' and address<>'' and phone<>''
这样就限定查询结果中name,address,phone都必须有值
#3
w4219475452008-09-16 09:22
同意二楼
#4
yellowray2008-09-16 09:54
谢谢2楼..这么快就帮我解决了
#5
iorivsmu2008-09-16 10:06
可不可以用where name<>nall?
#6
seiya0278482008-09-16 10:34
[bo][un]iorivsmu[/un] 在 2008-9-16 10:06 的发言:[/bo]

可不可以用where namenall?

如果要判断字段值为null的时候,要用where name is not null 或者 where name is null,而不能用where name<>null,这样是不对的
#7
卜酷塔2008-09-16 18:17
同意除5楼以外的所有楼上
#8
ggsdduyoyo2008-09-18 11:20
有意思!
#9
xiaoyuaner3282008-09-18 15:40
同意七楼
#10
师妃暄2008-09-18 15:46
同意九楼
#11
西风独自凉2008-09-18 17:41
select * from A  where isnull(name,'')<>''  and isnull(address,'')<>'' and isnull(phone,'')<>''
#12
jxyga1112008-09-18 20:11
同意10樓不同意11樓
#13
hxwantres2008-10-13 16:51
还是版主想的周到
1