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

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

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

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

相關文章:
主站蜘蛛池模板: 长治县| 勃利县| 永定县| 罗源县| 台北县| 镶黄旗| 包头市| 宁强县| 隆昌县| 麻江县| 东阳市| 吉木萨尔县| 雷州市| 淮南市| 松桃| 宁化县| 晋宁县| 青铜峡市| 正安县| 绥中县| 绥阳县| 攀枝花市| 凌源市| 永安市| 德州市| 灵山县| 南澳县| 三亚市| 闽清县| 枣庄市| 多伦县| 大名县| 革吉县| 历史| 岚皋县| 古丈县| 利川市| 沧州市| 韶关市| 隆化县| 信丰县|