left join左连接,是返回左表中所有的行及右表中符合条件的行。
right join右连接,是返回右表中所有的行及左表中符合条件的行。
full join全连接,是返回左表中所有的行及右表中所有的行,并按条件连接。
通常情况下,left join肯定比inner join返回的行数多。
为什么会多呢:
假设 a ,b 2个表
要查a的数据 b当做关联
select a.* from a left join b on a.id = b.aid where b.type=12
这是个左连接 当b表里多出一个type=12时数据不改变
select a.* from a right join b on a.id = b.aid where b.type=12
会多出一个type=12的数据 左边表的数据则用null填充
inner join则会2者同时存在才会查出