【发布时间】:2015-12-28 05:19:46
【问题描述】:
假设我有 2 张桌子。
TableA 只有一列,看起来像这样(它总是只有一列,但该列中的值会随着时间而变化):
TableA
------
Column1:
A
G
T
R
表 B 有很多列(但这些列都不会匹配表 A 的 column1 中的值)。即
TableB
------
Column1: Column2: Column3:
65 xyz fgdsg
97 tmkl sjg
184 soi trhd
我希望能够在查询中返回以下结果集:
TabA.Column1: TabB.Column1: TabB.Column2: TabB.Column3:
------------- ------------ ------------ ----------
A 65 xyz fgdsg
A 97 tmkl sjg
A 184 soi trhd
G 65 xyz fgdsg
G 97 tmkl sjg
G 184 soi trhd
T 65 xyz fgdsg
T 97 tmkl sjg
T 184 soi trhd
R 65 xyz fgdsg
R 97 tmkl sjg
R 184 soi trhd
为了做到这一点,我想联合 TableB x 次,其中 x 是 TableA 的计数,但我认为您不能仅在 SQL 中动态创建 x 个联合。我只是在寻找 SQL 代码中的解决方案(它可能包含使用预定义的 PL/SQL 函数)。
【问题讨论】:
-
只是“交叉连接”不起作用? (不需要 where 子句)。