内连接 inner join ....on...../join ....on... :将两个表中同时符合on条件的记录查询出来 inner可以省略
select *from person inner join card on person.cardid=card.cardid;
外连接 分为左连接、右连接,完全连接
左连接:left join ....on....将左表记录完全输出,满足条件的右表记录输出,左表对应的右表不满足条件就补null
select *from person left join card on person.cardid=card.cardid;
右连接:left join ....on....将右表记录完全输出,满足条件的左表记录输出,右表对应的左表不满足条件就补null
select *from person right join card on person.cardid=card.cardid;
完全连接:将左表和右表中所有的记录全部输出,用union实现多个select语句的联合查询,将查询结果合并,去除重复的记录。
select *from person left join card on person.cardid=card.cardid
-> union
-> select *from person right join card on person.cardid=card.cardid;