1: SELECT c.CustomerId, CompanyName 2: FROM Customers c 3: WHERE EXISTS( 4: SELECT OrderID FROM Orders o 5: WHERE o.CustomerID = cu.CustomerID) 像這樣的EXISTS子查詢中的SELECT什么根本不重要,因為子查詢只是檢查這個表中有沒有滿足WHERE后條件的行, 有就返回TRUE,沒有就FALSE,所以很多EXISTS后都是SELECT的*
一行行的去判定,EXISTS返回的是TRUE,就是存在,則把這行的相關信息輸出
1: select distinct 姓名 from xs 2: where not exists ( 3: select * from kc 4: where not exists ( 5: select * from xs_kc 6: where 學號=xs.學號 and 課程號=kc.課程號 ) 分析下上面的查詢語句: