| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛

问题点数：0 回复次数：6

Create Table [dbo].[t1]([fid] [int] Null,[a1] [char](10) Null) On [PRIMARY]
Create Table [dbo].[t2]([fid] [int] Null,[entryid] [int] Null,[a1] [nchar](10) Null) On [PRIMARY]
Create Table [dbo].[t3]([nid] [int] Null,[entryid] [int] Null,[a1] [char](10) Null) On [PRIMARY]

insert into t1(fid,a1) values(1,'a1')
insert into t1(fid,a1) values(2,'a1')
insert into t1(fid,a1) values(3,'a1')

insert into t2(fid,entryid,a1) values(1,1,'a1')
insert into t2(fid,entryid,a1) values(1,2,'a1')
insert into t2(fid,entryid,a1) values(1,3,'a1')
insert into t2(fid,entryid,a1) values(1,3,'a1')

insert into t3(nid,entryid,a1) values(1,3,'a1')
insert into t3(nid,entryid,a1) values(2,3,'a1')

select * from t1 left join t2 on t2.fid=t1.fid inner join t3 on t3.entryid=t2.entryid and t3.nid=999

select * from t1 left join (select t2.fid,t2.entryid,t3.a1 from t2 inner join t3 on t3.entryid=t2.entryid and t3.nid=999) as mx on mx.fid=t1.fid

[此贴子已经被作者于2022-7-29 09:07编辑过]

select * from t1 left join (select t2.fid,t2.entryid,t3.a1 from t2 inner join t3 on t3.entryid=t2.entryid and t3.nid=999) as mx on mx.fid=t1.fid

select * from t1 left join t2 on t2.fid=t1.fid inner join t3 on t3.entryid=t2.entryid and t3.nid=999

select * from t1 left join t2 on t2.fid=t1.fid

inner join t3 on t3.entryid=t2.entryid and t3.nid=999

[此贴子已经被作者于2022-7-29 09:48编辑过]

。。。(
select t2.fid, t2.entryid, t3.a1
from t2
inner join t3 on t3.entryid = t2.entryid
where t3.nid = 999
) as mx 。。。

[此贴子已经被作者于2022-7-29 10:26编辑过]

• 7
• 1/1页
• 1