文章詳情頁(yè)
mysql - 下面語(yǔ)句用left join 還是用not in?
瀏覽:181日期:2022-06-11 16:23:39
問(wèn)題描述
實(shí)現(xiàn):查詢(xún)a中沒(méi)有關(guān)聯(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
那種更好,或者有其他的方式,請(qǐng)大神留下答案
問(wèn)題解答
回答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ū)別
相關(guān)文章:
1. javascript - immutable配合react提升性能?2. javascript - sublime快鍵鍵問(wèn)題3. javascript - nodejs關(guān)于進(jìn)程間發(fā)送句柄的一點(diǎn)疑問(wèn)4. Apache 已經(jīng)把網(wǎng)站根目錄的改為allow from all了,但是服務(wù)器還是不能訪問(wèn)?5. 實(shí)現(xiàn)bing搜索工具urlAPI提交6. javascript - 移動(dòng)端上不能實(shí)現(xiàn)拖拽布局嗎?7. vue.js - Vue 如何像Angular.js watch 一樣監(jiān)聽(tīng)數(shù)據(jù)變化8. phpstudy8.1支持win11系統(tǒng)嗎?9. 配置Apache時(shí),添加對(duì)PHP的支持時(shí)語(yǔ)法錯(cuò)誤10. css - 寫(xiě)頁(yè)面遇到個(gè)布局問(wèn)題,求大佬們幫解答,在線等,急!~
排行榜

熱門(mén)標(biāo)簽
網(wǎng)公網(wǎng)安備