成都创新互联网站制作重庆分公司

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://cxhlcq.com/article/piijsg.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部