首页 > 编程知识 正文

MySQL 左连接与右连接区别,mysql左连接与右连接

时间:2023-05-06 05:44:17 阅读:223031 作者:365

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

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。