文章详情页
mysql 联表查询
浏览:156日期:2022-06-21 18:53:02
问题描述
A表order_id data 1 1 2 2 3 3B表order_id state 11 22
查找A中与B不重复的对应order_id的data(即order_id=3的data),sql语句怎么写?
问题解答
回答1:select data from a where order_id not in ( select distinct order_id from b );回答2:
select datafrom A left join B on A.order_id = B.order_idwhere isnull(B.state)
回答3:select * from A where order_id not in (select order_id from B)回答4:
SELECT a.data FROM a LEFT JOIN b ON a.order_id=b.order_id WHERE b.order_id IS NULL回答5:
select data from A where A.id not IN (select B.id from B)
回答6:select data from a where not exists (select 1 from b where a.order_id = b.order_id)
相关文章:
1. javascript - npm下载的模块不完整是什么问题?2. java - Spring事务回滚问题3. wordpress - Nginx中禁止访问txt,robots.txt文件例外,规则该怎么写?4. python运行后没有任何反馈要怎么排查5. node.js - 我想让最后进入数据库的数据,在前台最先展示,如何做到?6. MySQL数据库服务器循环插入执行速度慢7. 刚放到服务器的项目出现这中错误,有高手指点吗8. apache - 本地搭建wordpress权限问题9. python 操作mysql如何经量防止自己的程序在之后被恶意注入(说白了就是问一下python防注入的一些要点)10. mysql - 面试题:如何把login_log表转换成last_login表?
排行榜
