ORACLE不等于条件会过滤掉值为null的记录

不等于符号会把code为null的记录过滤掉

SELECT * FROM person WHERE sex='' and code != 'xxx';

解决方法:

SELECT * FROM person WHERE sex='' and (code != 'xxx' or code is null);

SELECT * FROM person WHERE sex='' and NVL(code,0) != 'xxx';
posted @ 2020-10-10 16:37  芃蓉蓁蓁  阅读(849)  评论(0编辑  收藏  举报