|
|
关于:
QUESTION 203:
Which three statements about subqueries are true? (Choose three.)
A.A main query can have more than one subquery.
B.A subquery can have more than one main query.
C.The subquery and main query must retrieve data from the same table.
D.The subquery and main query can retrieve data from different tables.
E.Only one column or expression can be compared between the subquery and main query.
F.Multiple columns or expression can be compared between the subquery and main query.
Answer: A, C, E
又是子查询,A同意,C明显不对,select a from b where b.c =select e.c from e应为D
我记得F可以select a from b where (a,c)in select e.a,e.c from e,见sg 18-6Multiple-Column Subqueries那E就错了
===============================================================================
我认为正确的答案是:ADF
关于F:在一个资料中我看到这样的一段话
If you want compare two or more columns. you must write a compound WHERE clause using logical operators Multiple-column subqueries enable you to combine duplicate WHERE coditions into a single WHERE clause.
Using Multiple-Column Subqueries
Display the order number, product number, and quantity of any item in
which the product number and quantity match both the product number
and quantity of an item in ordid 365.
SELECT ordid, prodid, qty
FROMitem
WHERE (prodid, qty) IN
(SELECT prodid, qty
FROM item
WHERE ordid = 365)
AND ordid = 365 ;
ORDID PRODID QTY
365 84 22
当然也可以写成这样
Nonpairwise Comparison Subguery
Display the order number, product number, and quantity of any item in
which the product number and quantity match any product number and any
quantity of an item in order 605.
SELECT ordid, prodid, qty
FROM item
WHERE prodid IN (SELECT prodid
FROM Item
WHERE ordid = 365)
AND qty IN (SELECT qty
FROM item
WHERE ordid = 365)
AND ordid = 365 ;
ORDID PRODID QTY
365 84 22 |
|