假设我有2个表。将整个记录集返回x次(其中x是另一个表中的行数)
表A只有一列,看起来像这样(它将始终只有一个列,但该列中的值将随时间而变化):
TableA
------
Column1:
A
G
T
R
表B有许多列(但这些都不列将永远匹配来自表A的列1的值)。即
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
要做到这一点,我想unioning表B x次,其中x是从TableA的,但我的计数不要以为你可以在SQL中动态地创建x个联合。我只在SQL代码中寻找解决方案(它可能包含使用预定义的PL/SQL函数)。
只是“交叉连接”不起作用? (不需要where子句)。 – 2011-04-01 23:50:52