大家帮我看看,奇怪的sql问题,在线等
有一个表中的一个字段名为ysmc,VARCHAR2(20),非主键
插入四笔资料
张三
null
李四
张三
我这样查询
select * from si_cfxx where ysmc='张三'
得到两条记录;
select * from si_cfxx where ysmc='张三'
得到一条记录;李四
为什么找不到等于null的那条呢?
问题点数:20、回复次数:3Top
1 楼cenlmmx(学海无涯苦作舟)回复于 2006-03-03 16:02:09 得分 10
null是不能比较的,null<>null,只能是is null或者 is not null
select * from si_cfxx where nvl(ysmc,' ')='张三'
Top
2 楼yxxx(_小孬)回复于 2006-03-03 16:07:28 得分 10
select * from si_cfxx where ysmc is nullTop
3 楼woaiDelphi(为了美好的明天)回复于 2006-03-03 16:26:53 得分 0
谢谢两位,马上给分Top




