oracle中not in(null)问题
2014-09-19 14:14
176 查看
如下sql语句
select aid from A where bid not in(select bid from B where bname='')
如果bname的记录在数据库中没有 就相当于 in(null) 此时 not in(null) 按理是要查询所有的A表中的记录
事实确实一条都没查出来
可以用以下语句测试以下
select aid from A where bid not in(null)
其实就是因为 相当于 bid!=null 这样是没有记录查询出来的
如果用 bid is null就能查询出来
可以修改sql语句未
select aid from A where bid not in(select nvl(bid,'-1') from B where bname='')
这样不会出现空的结果 将-1当作空来使用 前提是bid中不能出现 -1的结果 不然就不行了
-1的值视情况而定
select aid from A where bid not in(select bid from B where bname='')
如果bname的记录在数据库中没有 就相当于 in(null) 此时 not in(null) 按理是要查询所有的A表中的记录
事实确实一条都没查出来
可以用以下语句测试以下
select aid from A where bid not in(null)
其实就是因为 相当于 bid!=null 这样是没有记录查询出来的
如果用 bid is null就能查询出来
可以修改sql语句未
select aid from A where bid not in(select nvl(bid,'-1') from B where bname='')
这样不会出现空的结果 将-1当作空来使用 前提是bid中不能出现 -1的结果 不然就不行了
-1的值视情况而定
相关文章推荐
- Oracle not in子连接查询不到值的问题(not in 不能查询null数据)
- Oracle 在not in中使用null的问题
- ORACLE 在not in中使用null的问题
- ORACLE 在not in中使用null的问题
- Oracle Null 与 in, exists 的关系说明(not in 查不到结果)
- 解决mybatis在oracle中null的问题
- ORACLE中null的排序问题
- sql server和oracle中关于null和''的问题
- oracle、sqlserver数据库排序空值null问题解决办法
- Oracle中null的比较问题
- Oracle Null 与 in, exists 的关系说明(not in 查不到结果)
- oracle、sqlserver数据库排序空值null问题解决办法
- oracle在线重定义拷贝表结构的NOT NULL约束问题
- oracle中关于null排序的问题
- oracle中的null问题 in与exists
- java.lang.NullPointerException at oracle.jdbc.dbaccess.DBData.clearItem(DBData.java:431)问题解决
- 【Attention】Oracle查询时值为NULL的问题
- oracle、sqlserver数据库排序空值null问题解决办法
- Oracle安装出现 安装检测到系统的主IP地址是DHCP分配的地址 及 无法与该代理取得联系。请验证此代理的 url 是否为 null 问题解决
- Oracle Null 与 in, exists 的关系说明(not in 查不到结果)