文章詳情頁
mysql - 下面語句用left join 還是用not in?
瀏覽:111日期:2022-06-11 16:23:39
問題描述
實現(xiàn):查詢a中沒有關聯(lián)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的區(qū)別
相關文章:
1. python - 如何用pandas處理分鐘數(shù)據(jù)變成小時線?2. form表單中的label標簽3. Python中使用超長的List導致內存占用過大4. pdo - mysql 簡單注入疑問5. 雙擊安裝程序,安裝不了6. javascript - dropload+tab頁面,圖文頁滾動有兩個滾動區(qū)域怎么破?7. windows-7 - Win7中Vmware Workstatoin與Xampp中Apache服務器端口沖突?8. python - Pycharm的Debug用不了9. html5 - 百度echart官網(wǎng)下載的地圖json數(shù)據(jù)亂碼10. javascript - 求救!網(wǎng)頁播放視頻只有聲音沒有畫面,網(wǎng)頁上傳視頻文件時怎么知道視頻的編碼為H264還是MPEG4??
排行榜

熱門標簽