Bo's Oracle Station

查看: 1534|回复: 0

关联子查询如果可能把它改成普通子查询:

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2020-9-13 21:14:57 | 显示全部楼层 |阅读模式
  1. SELECT employee_id,salary,last_name FROM employees M
  2. WHERE EXISTS
  3. (SELECT 'X'  FROM employees W
  4. WHERE (W.manager_id=M.employee_id) AND W.salary > 10000);

  5. SELECT employee_id,salary,last_name FROM employees M
  6. WHERE  employee_id in
  7. (SELECT W.manager_id  FROM employees W
  8. WHERE (W.manager_id=M.employee_id) AND W.salary > 10000);

  9. SELECT employee_id,salary,last_name FROM employees M
  10. WHERE   employee_id  in
  11. (SELECT manager_id   FROM employees
  12. WHERE  salary > 10000);




  13. SELECT * FROM departments
  14. WHERE NOT EXISTS
  15. (SELECT * FROM employees
  16. WHERE employees.department_id=departments.department_id);


  17. SELECT * FROM departments
  18. WHERE not exists
  19. (SELECT 'X'   FROM employees
  20. WHERE employees.department_id=departments.department_id);

  21. SELECT * FROM departments
  22. where department_id not in
  23. (select  department_id  from employees  where department_id is not null  );


复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-11-21 23:54 , Processed in 0.040396 second(s), 25 queries .

快速回复 返回顶部 返回列表