MySQL多表查询

1. 两张表都有的记录

select * from Table_1 where exists (select Column_2 from Table_2 where Colomn_2=Table_1.Column)

2. 表一有表二没有的记录

select * from Table_1 where not exists (select Column_2 from Table_2 where Colomn_2=Table_1.Column)

3. 表二有表一没有的记录

select * from Table_2 where not exists (select Column_1 from Table_1 where Colomn_1=Table_2.Column)
    原文作者:jas0n
    原文地址: https://segmentfault.com/a/1190000006889167
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞