MySQL中连表查询分为等值连接和非等值连接

1.等值连接:



二)非等值连接:


#案例:查询部门编号在10-90之间的员工的工资级别,并按级别进行分组
SELECT * FROM sal_grade;


SELECT COUNT(*) 个数,grade
FROM employees e
JOIN sal_grade g
ON e.`salary` BETWEEN g.`min_salary` AND g.`max_salary`
WHERE e.`department_id` BETWEEN 10 AND 90
GROUP BY g.grade;


本人新手,肯定有理解错误的地方,还请大家不吝赐教,多多给予批评指正!
万般感谢!!!

posted @ 2022-03-15 16:27  怎言笑i  阅读(188)  评论(0编辑  收藏  举报