SQL语句各种join用法(图文)

1、INNER JOIN(内连接)
在这里插入图片描述
select * from table A A inner join table B B on A.key = B.key //内连接
2、LEFT JOIN(左连接)
在这里插入图片描述
select * from table A A left join table B B on A.key = B.key //左连接
3、RIGHT JOIN(右连接)
在这里插入图片描述
select * from table A A right join table B B on A.key = B.key //右连接
4、OUTER JOIN(外连接)
在这里插入图片描述
select * from table A A full outer join table B B on A.key = B.key //外连接
5、LEFT JOIN EXCLUDING INNER JOIN(左连接-内连接)
在这里插入图片描述
select * from table A A left join table B B on A.key = B.key where B.key is null //左连接 - 内连接
6、RIGHT JOIN EXCLUDING INNER JOIN(右连接-内连接)
在这里插入图片描述
select * from table A A right join table B B on A.key = B.key where A.key is null //右连接 - 内连接
7、OUT JOIN EXCLUDING INNER JOIN(外连接-内连接)
在这里插入图片描述
select * from table A A full outer join table B B on A.key = B.key where A.key is null or B.key is null //外连接 - 内连接

猜你喜欢

转载自blog.csdn.net/HuanJun_/article/details/88647208
今日推荐