跳转至

嵌套查询

题目

查询总经办的男性职工的岗位名称。

SELECT positions.positions_title FROM staff INNER JOIN positions ON positions.positions_id = staff.positions_id INNER JOIN section ON section.section_id = staff.section_id WHERE staff.sex = '男' AND section.section_title = '总经办'

工资比张向阳的工资高的员工姓名

SELECT staff.`name` FROM staff WHERE staff.money > (SELECT staff.money FROM staff WHERE staff.`name` = '张向阳');

查询工资比研发部职工工资高的员工姓名

SELECT staff.`name` FROM staff WHERE staff.money > (SELECT MIN(staff.money) AS minmoney FROM staff INNER JOIN section ON staff.section_id = section.section_id WHERE section.section_title = '研发部');

查询工资比研发部全部职工工资高的员工姓名。

SELECT staff.`name` FROM staff WHERE staff.money > (SELECT MAX(staff.money) AS maxmoney FROM staff INNER JOIN section ON staff.section_id = section.section_id WHERE section.section_title = '研发部');