文章詳情頁
mysql - 下面語句用left join 還是用not in?
瀏覽:127日期: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. node.js - 為什么用file協議打開的html可以連接websocket2. javascript - 為什么express,get的res.sendFile返回的是html純文本?3. CSS3中偽類選擇器的問題??求大神們解答4. node.js - 為什么npm安裝vue-cli會出現下面的錯誤??!!!?5. 微信支付 - python做微信企業付款出現CA證書錯誤6. 了解Java中的有限泛型。有什么意義?7. javascript - 用jquery實現表格行 置頂之后 如何跟后臺用ajax交互 在刷新之后仍保持當前位置?8. 前端 - css3傾斜帶來問題部分?9. javascript - Web微信聊天輸入框解決方案10. 網站在移動的環境下手機,pc打不開
排行榜
