-- 非等值连接
-- 案例:查询员工的工资级别
SELECT salary, grade_level
FROM employees e
JOIN job_grades g
ON e.salary BETWEEN g.lowest_sal AND g.highest_sal
ORDER BY salary;
-- 案例:查询每个工资级别的个数(>2),按照级别降序
SELECT grade_level,COUNT(salary)
FROM employees e
JOIN job_grades g
ON e.salary BETWEEN g.lowest_sal AND g.highest_sal
GROUP BY grade_level
HAVING COUNT(salary)>10
ORDER BY grade_level DESC;
07.2sql99语法-内连接-非等值连接——MySQL
最新推荐文章于 2024-03-08 11:48:32 发布