左连接的含义: 使用 LEFT JOIN 关键字,会从 左表 那里返回所有的行,即使在 右表 中没有匹配的行。
1)左连接
select a.*, b.*
from table1 a
left join table2 b
on a.id = b.parent_id
2) 内连接
select a.*, b.*
from table1 a
inner join table2 b
on a.id = b.parent_id
或
select a.*, b.*
from table1 a
join table2 b
on a.id = b.parent_id
内连接写成 inner join 或 join,没区别