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 
)

  

猜你喜欢

转载自www.cnblogs.com/vegetableDD/p/11641110.html