首先先建两个表,student表和score表
student
score
1.内连接只显示两表中有关联的数据
select * from student inner join score on student.sid = score.stu_id
2.左连接显示左表所有数据,右表没有对应的数据用NULL补齐,多了的数据删除(从结果可以看出在score表中没有数据的部分用NULL代替)
select * from student left join score on student.sid = score.stu_id;
3.右连接显示右表所有数据,左表没有对应的数据用NULL对齐,多了的数据删除(score表中没有的数据student表也不显示)
select * from student right join score on student.sid = score.stu_id;
默认连接是内连接