SQL的三种连接方式内连接、左连接、外连接

1.内连接

select * from table_a x inner join table_b y on x.a_id = y.b_id

返回两个表关键字x.a_id = y.b_id的交集数据集

2.左连接:left join 是left outer join的简写

select * from table_a x left join table_b y on x.a_id = y.b_id

左连接,左表的记录将会全部表示出来,右表只会显示符合搜索条件x.a_id = y.b_id的记录,右表记录不足的地方均为NULL。

3.右连接:right join 是right outer join的简写

select * from table_a x right join table_b y on x.a_id = y.b_id

右连接,右表的记录将会全部表示出来,左表只会显示符合搜索条件x.a_id = y.b_id的记录,左表记录不足的地方均为NULL。

原文地址:https://www.cnblogs.com/wzdLY/p/9700203.html