文章详情页
mysql 联表查询
问题描述
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. mac里的docker如何命令行开启呢?2. docker pull 错误?3. nginx+uwsgi部署django,8000端口正常,80端口4044. docker-compose 为何找不到配置文件?5. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?6. android-studio - android studio导入.so文件问题?7. javascript - js 对象深拷贝和赋值8. 在windows下安装docker Toolbox 启动Docker Quickstart Terminal 失败!9. mac连接阿里云docker集群,已经卡了2天了,求问?10. html5 - 移动端UC浏览器兼容问题
排行榜