我想把某一字段不为空的记录找出来,有以下SQL语句:
select buyDate as 购买日期, IC_number as 会员卡号 from tableName where IC_number is not null 按以上语句,应是会员卡号不为空的记录才会显示出来,但现在显示的结果却夹杂着几条IC_number为空的记录。我已检查为空的那几条记录IC_nubmer列什么也没有,包括' '.
请问各位大虾是什么原因呢?我该如何让那几样为空的也不显示出来?
我用的版本是oracle 10g。
先谢了!
select buyDate as 购买日期, IC_number as 会员卡号 from tableName where IC_number is not null 按以上语句,应是会员卡号不为空的记录才会显示出来,但现在显示的结果却夹杂着几条IC_number为空的记录。我已检查为空的那几条记录IC_nubmer列什么也没有,包括' '.
请问各位大虾是什么原因呢?我该如何让那几样为空的也不显示出来?
我用的版本是oracle 10g。
先谢了!
where (IC_number is not null) and (trim(IC_number) <> '')则没有找到任何一条记录。
不过我的版本是11g的。PL/SQL是7.11
如果是字符串就
select buyDate as 购买日期, IC_number as 会员卡号 from tableName where IC_number>'0';
是字符串,用 where IC_number>'0',空的记录还是会出来。
where (trim(IC_number) <> '')这样试下。
是字符串,用 where IC_number>'0',空的记录还是会出来。可是这个语句我真的在我这儿测试过,可以的。你不妨先把那个为空的记录字段update为null,再试试
请看图,倒数第二条便是。
你都把 is not null 条件注释掉了?
select buyDate as 购买日期, IC_number as 会员卡号 from tableName
where (IC_number is not null) and (trim(IC_number) <> '')则没有找到任何一条记录。select buyDate as 购买日期, IC_number as 会员卡号 from tableName
where trim(IC_number) is not null
insert into scott.dfs values(chr(10)||chr(13));
commit;
select * from scott.dfs where v_name is not null;
会不会跟我用 left join 有关呢?见我上面的图。
谢谢!
ass_number is not null
试试。
因为left join后,表里面已经没有ls_ic_number列了。
已经用过 is not null了。还是不行。
已经用过 is not null了。还是不行。LEFT JOIN 关键字会从左表 (table_name1) 那里返回所有的行,即使在右表 (table_name2) 中没有匹配的行。所以,应该添加ass_number is not null 的判断条件。注意,这里是 ass ,不是 ls 了。