文章详情页
mysql - 下面语句用left join 还是用not in?
浏览:230日期: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 - 请问一下npm 如何卸载之前的版本安装新的版本呢?2. javascript - 方法要用到一个外部的数据 那么是优先选择当成参数传过去 还是把数据存成相对当前作用域来说全局的变量~3. javascript - 请问一下fullpage只能初始化一次的问题怎么解决?4. html5 - html2canvas生成的图片,checkbox和radio的选中项无法截图。5. javascript - tab切换点击不同的按钮显示不同的内容6. javascript - 如何使用loadash对[object,object,object]形式的数组进行比较7. html5 - input type=’file’ 上传获取的fileList对象怎么存储于浏览器?8. javascript - 请教移动端从详情页返回到列表页原来位置的问题?9. javascript - vueclick事件点击时报错10. nginx英文文档的WebSocket proxying部分没看太明白,麻烦推荐一点中文文章
排行榜

网公网安备