mysql列子查询-成都快上网建站

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://kswjz.com/article/piijsg.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流