思路一 : 采用 not exists
select Name Customers
from Customers c
where not exists(select 1 from Orders o where o.CustomerId = c.Id)
直接在表 Customers 中查询 id号不在表 Orders 中的 数据,采用exists得到出现过的采购过的客户id,再取反
思路二: not in(采用集合方式排除在Orders表中出现的客户id)
select Name Customers
from Customers c
where Id not in (select CustomerId from Orders);
思路三: 左外连接
select Name Customers
from Customers c left outer join Orders o on c.Id = o.CustomerId
where o.Id is null;