文章详情页
mysql - 下面语句用left join 还是用not in?
浏览:191日期: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. notepad+编写的html,打开就是这样了。为什么,大神们2. Mysql取下一条记录3. 求助一个Android控件名称4. javascript 如何下载一个excel文件 ?5. Chrome-org.openqa.selenium.WebDriverException:未知错误:无法在driver.manage()window()maximize();处获得自动化扩展6. mysql federated引擎无法开启7. python 操作mysql如何经量防止自己的程序在之后被恶意注入(说白了就是问一下python防注入的一些要点)8. python3.x - python连oanda的模拟交易api获取json问题第五问9. python 如何打印bytes以16进制输出10. python - 如何使用websocket在网页上动态示实时数据的折线图?
排行榜

网公网安备