|
探讨一下Pairwise Comparison Subquery和Nonpairwise Comparison Subquery
做TK发现一题:
Which statement about multiple column subqueries is
true?
A. A pairwise comparison produces a cross product.
B A nonpairwise comparison produced a cross
product.
C. In a pairwise subquery, the values returned from the
subquery are compared individually to the values in the
outer query.
D. In a nonpairwise subquery, the values returned from
the subquery are compared are compared as a group to
the values in the outer query.
答案是B
搞不懂后来在SG 9i v2上查到相关内容,摘录如下
1.Pairwise Comparison Subquery
Display the details of the employees who are managed
by the same manager and work in the same department
as the employees with EMPLOYEE_ID 178 or 174.
SELECT employee_id, manager_id, department_id
FROM employees
WHERE (manager_id, department_id) IN
(SELECT manager_id, department_id
FROM employees
WHERE employee_id IN (178,174))
AND employee_id NOT IN (178,174);
2.Nonpairwise Comparison Subquery
Display the details of the employees who are managed by
the same manager as the employees with EMPLOYEE_ID
174 or 141 and work in the same department as the
employees with EMPLOYEE_ID 174 or 141.
SELECT employee_id, manager_id, department_id
FROM employees
WHERE manager_id IN
(SELECT manager_id
FROM employees
WHERE employee_id IN (174,141))
AND department_id IN
(SELECT department_id
FROM employees
WHERE employee_id IN (174,141))
AND employee_id NOT IN(174,141);
两者的输出结果是不一样的。看了之后还是不太理解。
明白的大侠能不能给解释一下啊 |
|