子查询
select * from employees
where job_id in (SELECT job_id from employees where first_name = 'Diana')
-- 效果相同
select * from employees
where job_id = (SELECT job_id from employees where first_name = 'Diana')在把select的结果当作表来查询时,必须起别名
select SUM(salary) from (select * from employees order by salary desc limit 5) temp多表查询
select e.employee_id, e.first_name, e.salary, d.department_name, j.job_title, j.min_salary, j.max_salary
from employees e LEFT JOIN departments d on e.department_id = d.department_id
LEFT JOIN jobs j on e.job_id = j.job_id