mysql--从不订购的客户

                                                

 

解法一:(左外连接 + not null)

select A.Name as Customers
from Customers A left join Orders B
on A.Id = B.CustomerId
where B.Id is null

  

解法二:(not in + 子查询)

 

select Name  as Customers  from Customers c where c.Id not in(
    select CustomerId from Orders 
)

 

  

 

posted @ 2019-10-09 13:04  Shawn_Michaels  阅读(149)  评论(0编辑  收藏  举报