文章詳情頁
mysql - 下面語句用left join 還是用not in?
瀏覽:176日期: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. docker鏡像push報錯2. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””3. Docker for Mac 創建的dnsmasq容器連不上/不工作的問題4. javascript - 請指條明路,angular的$event,在select中卻是undefined?5. docker - 如何修改運行中容器的配置6. 前端 - @media query 使用出現的問題?7. 運行python程序時出現“應用程序發生異常”的內存錯誤?8. 利用IPMI遠程安裝centos報錯!9. phpstudy8.1沒集成mysql-front10. html - css氣泡,實現“倒三角(不知道算不算三角了)”可透明的。
排行榜

網公網安備