計算機小白QAQ,因為想找數分崗暑期實習所以充了會員想集中刷一下leetcode的mysql部分,寫這個系列博文和大家們交流一下,后面也會持續更新面經準備的一些問題,歡迎同好們一起交流,求大佬輕噴QAQ,因為自己初學也走了很多彎路,所以會盡量寫得詳細一點,如果可以幫助到后來的朋友們,請各位留言鼓勵一下哈哈哈哈,
183、從不訂購的客戶

思路1:利用左連接,將order中的customerid和customers中的id匹配,匹配不到的證明是沒有購買東西的用戶,
select Name as Customers
from Customers
left join Orders on Customers.Id=Orders.CustomerId
where Orders.Id is null
思路2:利用子查詢,提取order中所有的customerid,customer表中id不在其中的即為沒有購買東西的用戶,
select Name as Customers
from Customers
where Id not in (select CustomerId from Orders)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/253089.html
標籤:其他
上一篇:C語言編程>第二十一周 ① 下列給定程式中,函式fun的功能是:比較兩個字串,將長的字串的首地址作為函式值回傳。
