猜想:以下两条SQL等价select * from A left join B on A.ID=B.BID and B.BName=N'小明'select * from A left join (select * from B where B.BName=N'小明') B on A.ID=B.BID
为了方便验证,新建两张表A和B,然后插入6条数据到A表,3条数据到B表。语句如下:create table A( ID int identity(1,1) not null, AName nvarchar(300) null)create table B( ID int identity(1,1) not null, BID int not null, BName nvarchar(300) null)insert into B(BName,BID) values(N'小明',2)insert into B(BName,BID) values(N'小网',1)insert into B(BName,BID) values(N'小刚',1)insert into B(BName,BID) values(N'小蒋',1)insert into B(BName,BID) values(N'小赵',1)insert into B(BName,BID) values(N'小流',1)insert into A(AName) values(N'一班')insert into A(AName) values(N'二班')insert into A(AName) values(N'三班')
验证结果:
写作时间:2017-11-8
=====================================================================================
本文只代表本人的见解,可能存在错误,仅用于技术交流。如果你喜欢该文,可以扫下面的二维码打赏我(打赏敬请备注“博客园打赏”五字)。