国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

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

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

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

相關文章:
主站蜘蛛池模板: 桃园县| 贵德县| 湖北省| 芜湖县| 龙井市| 临西县| 博湖县| 裕民县| 尉氏县| 武邑县| 白水县| 临夏县| 光泽县| 岐山县| 余姚市| 武宁县| 石首市| 瑞丽市| 林西县| 平顶山市| 樟树市| 读书| 陇川县| 井研县| 施秉县| 称多县| 汶上县| 永新县| 珲春市| 重庆市| 施甸县| 大丰市| 衡阳县| 布尔津县| 盐亭县| 山丹县| 海盐县| 琼中| 长子县| 兴安县| 盐源县|