oracle not in查不出任何数据问题

not exists能查出数据

 SELECT * FROM students st WHERE  not exists(select 1 from stu_score ss where  st.id=ss.stu_id);

not in查不出任何数据

SELECT * FROM students st WHERE  st.id not in(select  ss.stu.id from stu_score ss );

原因:ss.stu.id包含NULL
修改:SELECT * FROM students st WHERE st.id not in(select ss.stu.id from stu_score ss where ss.stu.id is not null); --能查出数据

参照博文:https://blog.csdn.net/linbrain0000/article/details/34106531

posted @ 2020-10-10 12:21  芃蓉蓁蓁  阅读(738)  评论(0编辑  收藏  举报