文章详情页
mysql - 下面语句用left join 还是用not in?
浏览:184日期: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的区别
相关文章:
1. php - 微信开发验证服务器有效性2. java导入问题3. javascript - Ajax返回json格式之后的数据解析后取出来的数据为undefined?4. javascript - npm安装报错 系统w7 求大神解答5. javascript - vue.js 在使用期间遇到ios9.3.2不兼容问题6. css - 文字排版问题,内容都是动态抓出来的,字数不一定。如何对齐啊7. css3 - 微信前端页面遇到的transition过渡动画的bug8. 网页爬虫 - 关于Python的编码与解码问题9. 前端 - WebStrom安装了angularjs插件,但是没有语法提示10. 正则表达式 - Java:字符串替换带序号
排行榜

网公网安备