2022/12/20

LeetCode 183. Customers Who Never Order

問題:哪個使用者沒有訂單

解法:兩者共同之處在於Customers的id等於Order的customerId,Orders裡面的customerId會告訴你誰沒有訂單,那將有訂單之外的使用者排除掉即可
SELECT name AS Customers
FROM Customers
WHERE Customers.id NOT IN
      (SELECT customerId FROM Orders);