sqlcreate table Customers (
id int primary key ,
name varchar(20)
);
create table Orders (
id int primary key ,
customeriId int ,
foreign key (customeriId) references Customers(id)
);
insert into Customers values (1,'Joe'),(2,'Henry'),(3,'Sam'),(4,'Max');
insert into Orders values (1,3),(2,1);
select name as Customers
from Customers as c
where c.id not in
(select customeriId from Orders);
select name as Customers
from Customers left join Orders
on Customers.id = Orders.customeriId
where Orders.customeriId is null;
本文作者:yowayimono
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!