left join:返回包括左表中的所有记录和右表中联结字段相等的记录
right join :返回包括右表中的所有记录和左表中联结字段相等的记录
join(inner join) : 只返回两个表中联结字段相等的行
实例:
1.student表
2.score表
3.left join 结果
select a.name,b.subject_name,b.score from student a left join score b on a.id = b.student_id;
4.right join 结果
select a.name,b.subject_name,b.score from student a right join score b on a.id = b.student_id;
5.join 结果
select a.name,b.subject_name,b.score from student a join score b on a.id = b.student_id;
等价于:
select a.name,b.subject_name,b.score from student a,score b where a.id = b.student_id;
欢迎纠错。