IN的主查询,成对比较。
……WHERE (manager_id,department_id) in ((1,2),(3,4),……);
标量子查询:
示例:
SQL> select employee_id,last_name from employees e 2 order by (select department_name from departments d 3 where e.department_id=d.department_id);
EMPLOYEE_ID LAST_NAME ----------- ------------------------- 205 Higgins 206 Gietz 200 Whalen 100 King 101 Kochhar 102 De Haan 112 Urman 108 Greenberg 109 Faviet 110 Chen 111 Sciarra
EMPLOYEE_ID LAST_NAME ----------- ------------------------- 113 Popp 203 Mavris 107 Lorentz 105 Austin 103 Hunold
关联子查询:
语句的解析过程如图
|