mysql的几种join方法详解

数据库的几种join语句

  • 左连接
  • 右连接
  • 外连接
  • 内连接
  • 左内连接
  • 右内连接
  • 外连接-内连接

左连接

select from table_A A left join table_B B on A.key = B.key
mysql的几种join方法详解_第1张图片
注意此时当右边表里面没有此list内容时,内容会以null的形式显示

右连接

select from table_A A right join table_B B on A.key = B.key
mysql的几种join方法详解_第2张图片
注意此时当左边表里面没有此list内容时,内容会以null的形式显示

外连接

select from table_A A full out join table_B B on A.key = B.key
mysql的几种join方法详解_第3张图片

内连接

select from table_A A inter join table_B B on A.key = B.key
mysql的几种join方法详解_第4张图片

左内连接

select from table_A A left join table_B B on A.key = B.key where B.key is null

mysql的几种join方法详解_第5张图片

右内连接

select from table_A A left join table_B B on A.key = B.key where A.key is nullmysql的几种join方法详解_第6张图片

外连接-内连接

select from table_A A full out join table_B B on A.key = B.key where A.key is null or B.key is nullmysql的几种join方法详解_第7张图片

你可能感兴趣的:(数据库)