mysql 数据库关联表查询!
JOIN 内连接
LIFT JOIN 左连接
LEFT JOIN 有链接
student(学生表)
class(班级表)
1,JOIN 相当于INNER JOIN内连接,不满足on 的条件过滤掉,不显示
select * from student s Join class c on s.class_id = c.id
2,LIFT JOIN 左连接,以左表为主表, 不满足on 的条件留在左表,右边数据为NULL
select * from student s left join class c on s.class_id = c.id
3,RIGHT JOIN 右连接 以右表为主表,不满足on 条件的留在右表中,左表NULL
select * from student s right join class c on s.class_id = c.id