文章詳情頁
mysql - 下面語句用left join 還是用not in?
瀏覽:100日期: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. 百度地圖api - Android百度地圖SDK,MapView上層按鈕可見卻不可觸,怎么解決?2. javascript - jquery怎么給select option一個點擊時觸發的事件,如圖 如果選擇自定義觸發一個時間?3. mysql 獲取時間函數unix_timestamp 問題?4. 新入手layuiadmin,部署到tp中。想用php自已寫一個后臺管理系統。5. node.js - 在nodejs環境中如何配置webhook以實現hexo博客的自動更新?6. javascript - es6擴展運算符...的問題7. 網頁爬蟲 - python爬蟲用BeautifulSoup爬取<s>元素并寫入字典,但某些div下沒有這一元素,導致自動寫入下一條,如何解決?8. html5 - canvas中的mousedrag事件,為什么鼠標拖出canvas,然后再次移入canvas,drag事件還觸發9. css3 - 求教CSS圖標庫的寫法,也就是先做雪碧圖,然后寫一個css表,用的時候直接用class就可以了10. html - 前端大牛都頂一下!CSS鼠標樣式問題,如圖所示
排行榜
