文章詳情頁
mysql - 下面語句用left join 還是用not in?
瀏覽:99日期: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 for Mac 創建的dnsmasq容器連不上/不工作的問題2. docker安裝后出現Cannot connect to the Docker daemon.3. javascript - 請教空白文本節點的問題4. javascript - 用js實現遠程js調用時出現時間機制問題怎樣解決?5. 刷新頁面出現彈框6. javascript - 前端開發 本地靜態文件頻繁修改,預覽時的緩存怎么解決?7. ios - 類似微博首頁,一張圖的時候是如何確定圖大小的?8. java報錯Communications link failure 該如何解決?9. javascript - 怎么看網站用了什么技術框架?10. PC 手機兼容的 編輯器
排行榜
