文章详情页
mysql - 下面语句用left join 还是用not in?
浏览:202日期:2022-06-11 16:23:39
问题描述
实现:查询a中没有关联b的记录
1、select id from a left join b on a.id = b.aid where b.id is null and status = 1
2、select id from a where id not in (select aid from b) and status = 1
那种更好,或者有其他的方式,请大神留下答案
问题解答
回答1:not exists正解
select id from a where not exists (select 1 from b where a.id=b.aid) and status = 1回答2:
我想使用 not exists
浅谈sql中的in与not in,exists与not exists的区别
相关文章:
1. javascript - swiper.js嵌套了swiper 初始设置不能向下一个滑动 结束后重新初始2. html5和Flash对抗是什么情况?3. javascript - 如何将psd裁切下来的图片非常清晰的宣示出来4. html5 - 请问一下写H5的时候 你们都是兼容那些手机5. javascript - 如何找到页面中js function对应的源代码?6. javascript - 给js写的盒子添加css样式,css样式没起作用。7. mysqli函数8. 为什么javascript 18014398501093363 == 18014398501093364 返回ture9. javascript - vuex中action应该怎么分发事件10. 数据挖掘 - 如何用python实现《多社交网络的影响力最大化问题分析》中的算法?
排行榜
![php-_server-php_self - nginx $_SERVER[’PHP_SELF’] 得到重复路径是什么原因?](http://www.haobala.com/attached/image/news/202309/1123091c0c.png)
网公网安备