#案例:查询员工的工资级别 SELECT salary,grade_levelFROM employees eJOIN job_grades gON e.`salary` BETWEEN g.`lowest_sal` AND g.`lowest_sal`; #案例:查询每个工资级别的个数,并且按级别降序 SELECT COUNT(*),gra
#案例:查询员工的工资级别
SELECT
salary,grade_level
FROM
employees e
JOIN
job_grades g
ON
e.`salary` BETWEEN g.`lowest_sal` AND g.`lowest_sal`;
#案例:查询每个工资级别的个数,并且按级别降序
SELECT
COUNT(*),grade_level
FROM
job_grades j
JOIN
employees e
ON
e.`salary` BETWEEN j.`lowest_sal`AND j.`highest_sal`
GROUP BY
grade_level DESC;
内容扩展:
语法
select 查询列表
from 表1 别名 [连接类型]
jion 表2 别名
on 连接条件
[where 筛选条件]
[group by 分组]
[having 筛选条件]
[order by 排序列表]
案例1:查询员工名,部门名
SELECT last_name,department_name
FROM employees e
INNER JOIN departments d
ON e.department_id=d.department_id;
案例2:查询名字中包含e的员工名和工种名(添加筛选)
SELECT last_name,job_title
FROM employees e
INNER JOIN jobs j
ON e.job_id=j.job_id
WHERE e.last_name LIKE ‘%e%';
以上就是本次介绍的全部知识点内容。