编辑
2023-09-26
后端
00
请注意,本文编写于 592 天前,最后修改于 581 天前,其中某些信息可能已经过时。

目录

总结

image.png

image.png

sql
create 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;

总结

  • 左连接会返回左表所有记录和右表匹配记录

image.png

本文作者:yowayimono

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!