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

1、INNER JOIN(内连接)
SQL语句各种join用法(图文)_第1张图片
select * from table A A inner join table B B on A.key = B.key //内连接
2、LEFT JOIN(左连接)
SQL语句各种join用法(图文)_第2张图片
select * from table A A left join table B B on A.key = B.key //左连接
3、RIGHT JOIN(右连接)
SQL语句各种join用法(图文)_第3张图片
select * from table A A right join table B B on A.key = B.key //右连接
4、OUTER JOIN(外连接)
SQL语句各种join用法(图文)_第4张图片
select * from table A A full outer join table B B on A.key = B.key //外连接
5、LEFT JOIN EXCLUDING INNER JOIN(左连接-内连接)
SQL语句各种join用法(图文)_第5张图片
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(右连接-内连接)
SQL语句各种join用法(图文)_第6张图片
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(外连接-内连接)
SQL语句各种join用法(图文)_第7张图片
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 //外连接 - 内连接

你可能感兴趣的:(基础知识)