mysql列子查询
#案例:返回location_id是1400或1700的部门中的所有员工
创新互联是一家以成都网站建设、网页设计、品牌设计、软件运维、seo优化排名、小程序App开发等移动开发为一体互联网公司。已累计为成都橡塑保温等众行业中小客户提供优质的互联网建站和软件开发服务。
SELECT last_name
FROM employees
WHERE department_id IN(
SELECT DISTINCT department_id
FROM departments
WHERE location_id IN (1400,1700)
);
#案例:返回其他工种中比job_id为'IT_PROG'部门任一工资低的员工的员工号、姓名、job_id和salary
SELECT DISTINCT employee_id,last_name,job_id,salary
FROM employees
WHERE salary'IT_PROG' ;
或者
SELECT DISTINCT employee_id,last_name,job_id,salary
FROM employees
WHERE salary<(
SELECT DISTINCT MAX(salary)
FROM employees
WHERE job_id='IT_PROG'
) AND job_id <>'IT_PROG' ;
#案例:返回其他工种中比job_id为'IT_PROG'部门所有工资低的员工的员工号、姓名、job_id和salary
SELECT DISTINCT employee_id,last_name,job_id,salary
FROM employees
WHERE salary'IT_PROG' ;
或者
SELECT DISTINCT employee_id,last_name,job_id,salary
FROM employees
WHERE salary<(
SELECT DISTINCT MIN(salary)
FROM employees
WHERE job_id='IT_PROG'
) AND job_id <>'IT_PROG' ;
文章题目:mysql列子查询
浏览路径:http://cdiso.cn/article/piijsg.html