sql连接查询

1.内链接(inner join on)
  结果集是返回两个表中符合条件的数据,而舍弃不符合条件的语句
  select * from table1 inner join table2 on table1_id=table2_id where age>20
2.外连接
  (1)左外连接(left outer join/left join)
    返回所有的匹配行并从关键字join左边表中返回所有不匹配行,右边表中没有的用null填充
  (2)左外连接(right outer join/right join)
    返回所有的匹配行并从关键字join右边表中返回所有不匹配行,左边表中没有的用null填充
  (3)完整外部连接(full outer join/full join)
    返回两个表中所有匹配行和不匹配行
3.自身连接
  指表与自身连接 必须为每个连接表取一个别名
  select * from student s1 inner join student s2 on s1.id=s2.id where s2.xh='063823031'
原文地址:https://www.cnblogs.com/hubcarl/p/1412710.html