假設我有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