文章详情页
mysql 联表查询
浏览:213日期: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)
相关文章:
排行榜

网公网安备