各位大虾帮忙判断一下,以下这个问题用这两句SQL语句哪句执行时更快?数据库是access2000
问题:需要在3个表中读取满足同一个条件的数据一起返回。
表:A表、B表、C表
要返回的字段:Fa,Fb。(三个表都有这两个字段)
SQL语句1:
Select Fa,sum(Fb) as BB
From
(Select Fa,Fb From A表 Where Fa>100
Union All
Select Fa,Fb From B表 Where Fa>100
Union All
Select Fa,Fb From C表 Where Fa>100)
as UT
Group By Ut.Fa
SQL语句2:
Select Fa,BB
From
(Select Fa,sum(Fb) as BB
From A表 Inner Join B表 on A表.Fa=B表.Fa
Inner Join C表 on A表.Fa=C表.Fa
Group By A表.Fa) as Ut
Where Fa>100