久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

mysql - 下面語句用left join 還是用not in?

瀏覽:122日期: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的區別

相關文章:
主站蜘蛛池模板: 始兴县| 温泉县| 林甸县| 诏安县| 江西省| 崇州市| 航空| 五莲县| 仙桃市| 黎川县| 大港区| 麻栗坡县| 遵义县| 调兵山市| 十堰市| 衡东县| 河东区| 息烽县| 股票| 醴陵市| 临高县| 抚顺县| 浦北县| 资中县| 望城县| 依兰县| 长阳| 精河县| 突泉县| 阜新市| 奎屯市| 泌阳县| 周口市| 河间市| 特克斯县| 陆良县| 噶尔县| 海门市| 龙川县| 朔州市| 淳化县|