#案例:查询员工的工资级别

SELECT salary,grade_levelFROM employees eJOIN job_grades gON e.`salary` BETWEEN g.`lowest_sal` AND g.`lowest_sal`;

#案例:查询每个工资级别的个数,并且按级别降序

SELECT COUNT(*),grade_levelFROM job_grades jJOIN employees eON 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_nameFROM employees eINNER JOIN departments dON e.department_id=d.department_id;

案例2:查询名字中包含e的员工名和工种名(添加筛选)

SELECT last_name,job_titleFROM employees eINNER JOIN jobs jON e.job_id=j.job_idWHERE e.last_name LIKE ‘%e%';

以上就是本次介绍的全部知识点内容。