mysql-- never ordered customers

                                                

 

Method One: (outside the left connection + not null)

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

  

Solution two: (not in sub-queries +)

 

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

 

  

 

Guess you like

Origin www.cnblogs.com/vegetableDD/p/11641110.html