CROSS JOIN替代方案

时间:2013-10-24 15:21:10

标签: sql

我已经有了结果集,但我对具有相同结果的替代查询感兴趣。它们之间可能更好还是更快?

insert into [dbo].[Teams]  values(1,'First')
insert into [dbo].[Teams]  values(2,'Second')
insert into [dbo].[Teams]  values(3,'Third')
insert into [dbo].[Teams]  values(4,'Fourth')
insert into [dbo].[Teams]  values(5,'Fifth')

CREATE TABLE [dbo].[Team_team] (
[id1] [int] NOT NULL,
[id2] [int] NOT NULL
) ON [PRIMARY]
GO

select * from teams;

select t1.id,t2.id  from teams t2 cross join teams t1 

1 个答案:

答案 0 :(得分:0)

这与其他语法相同:

select t1.id,t2.id  from teams t1, teams t2

不会有性能差异。