sql
----内连接 inner join 或join
----外连接
1左连接 left join 或者left outer join
2 右连接 right join 或right outer join
3 完全外连接 full join 或 full outer join
---创建两个表
---person表
id
name
cardid
---card表
id
name
1 inner join(内连接)
select * from person inner join card on person.cardid = card.id
select * from person join card on person.cardid = card.id
-----内连查询:其实就是两张表的数据,通过某个字段相等,查询出相关记录工具。
2 .left join (左外连接)
select * from person left join card on person.cardid = card.id
select * from person left outer join card on person.cardid = card.id
-----左外连接:会把左边表里面的数据取出来,而右边表里的数据,如果有相等的,就显示出来,如果没有,就会补NUll
3 right join
select * from person right join card on person.cardid = card.id
select * from person right outer join card on person.cardid = card.id
-右外连接:会把右边表里面的数据取出来,而左边表里的数据,如果有相等的,就显示出来,如果没有,就会补NUll
4 full join
select * from person left join card on person.cardid = card.id
union
select * from person right join card on person.cardid = card.id
mysql不支持 full join