这两个查询是否相同/给出相同的输出?

时间:2011-12-28 11:52:41

标签: sql oracle subquery correlated-subquery

独立子查询

SELECT Cust_Name
 FROM Customer_Details              
   WHERE Cust_ID
     IN
      (SELECT Cust_ID
        FROM Customer_Loan)                
          AND Cust_ID IN
        (SELECT Cust_ID
          FROM Customer_Fixed_Deposit); 

相关子查询

SELECT Cust_ID
 FROM Customer_Details              
   WHERE Cust_ID
     IN
      (SELECT Cust_ID
        FROM Customer_Loan
         WHERE Customer_Loan.Cust_ID  = Customer_Details.Cust_ID)                
          AND Cust_ID IN
        (SELECT Cust_ID
          FROM Customer_Fixed_Deposit
   WHERE Customer_Fixed_Deposit.Cust_ID  = Customer_Details.Cust_ID); 

我们应该找到选择贷款的客户以及FD。

1 个答案:

答案 0 :(得分:2)

两者的最终输出相同。