62 Click the Exhibit button and examine the data from the ORDERS and
CUSTOMERS tables.
Evaluate the SQL statement:
SELECT *
FROM orders
WHERE cust_id = (SELECT cust_id
FROM customers
WHERE cust_name = 'Smith');
What is the result when the query is executed?
Answer: A该问题应该不是选择D嘛,SELECT cust_id FROM customers WHERE cust_name = 'Smith'选择的是多个值了使用=号不就报错了呀

解决方案 »

  1.   

    图片挂了,字查询有加条件WHERE cust_name = 'Smith',所以只返回一条数据。
      

  2.   

    图片挂了,楼主你的答案是这条SQL是错误的无法执行,对吧?
    估计出题人想考的是子查询,他的理想答案应当是oraders表中smith关联的所有记录。
    只能说这道题不够严谨,在cust_name有唯一索引的情况下SQL是正确的,否则有可能出错。
      

  3.   

    62 Click the Exhibit button and examine the data from the ORDERS and
    CUSTOMERS tables.
    Evaluate the SQL statement:
    SELECT *
    FROM orders
    WHERE cust_id = (SELECT cust_id
    FROM customers
    WHERE cust_name = 'Smith');
    What is the result when the query is executed? ORDERS
    ORD_ID ORD_DATE CUST_ID ORD_TOTAL
    100 2000/1/12 15 10000
    101 2000/1/13 40 8000
    102 2000/1/14 35 12500
    103 2000/1/15 15 12000
    104 2000/1/16 15 6000
    105 2000/1/17 20 5000
    106 2000/1/18 35 7000
    107 2000/1/19 20 6500
    108 2000/1/20 10 8000

    CUSTOMERS
    CUST_ID CUST_NAME CITY
    10 Smith los angeles
    15 Bob san francisco
    20 Martin chicago
    25 mary new york
    30 Rina chicago
    35 Smith new york
    40 Linda new york
    A.ORD_ID   ORD_DATE    CUST_ID ORD_TOTAL
     102 2000/1/14 35 12500
     106 2000/1/18 35 7000
     108 2000/1/20 10 8000
    B.ORD_ID ORD_DATE CUST_ID ORD_TOTAL
    102 2000/1/14 35 12500
    106 2000/1/18 35 7000
    C.ORD_ID ORD_DATE CUST_ID ORD_TOTAL
    108 2000/1/20 10 8000
    D.The query fails because the subquery returns more than one row.
    E.The query fails because the outer query and the inner query are using different tables.
    我把它手key了下来,帮忙分析下哈