cartesian product是cross join在数据库方面,你可以删除团队所在的相等行where条款:
select
t1.col1, t2.col1
from teams as t1
cross join teams as t2
where
t1.col1 <> t2.col1
Run Code Online (Sandbox Code Playgroud)
您可以将两个表连接在一起以获得预期的输出,如下所示:
select t1.col1, t2.col1
from table t1
join table t2
on t1.col1 <> t2.col1
Run Code Online (Sandbox Code Playgroud)