内连接:
内连接即等值连接
select a.name,b.age from a inner join b on a.id = b.id;
select a.name,b.age from a,b where a.id = b.id;
左连接:
在等值连接的基础上加上主表(左表)中未匹配的记录
select a.name,b.age from a left outer join b on a.id=b.id;
select a.name,b.age,c.sex from a left outer join b on a.id = b.id left outer join on a.id = c.id;
右连接:
在等值连接的基础上加上主表(右表)中未匹配的记录
select a.name,b.age from a right outer join b on a.id=b.id;
select a.name,b.age,c.sex from a right outer b on a.id = b.id right outer join c on b.id = c.id;
注意: 可以将a left outer join b on a.id = b.id看成是一张C表 on 后面的条件无论是否为真,都返回a表的全部记录