我目前正在寻找一个可以执行此操作的Select语句。
|------Apples------|
|--id--|
- 1
- 16
- 23
- 42
|------Oranges------|
|--id--|
- a
- b
- c
*SELECT STATEMENT*
|------Fruit Cocktail------|
|--AppleID--|--OrangeID--|
1 a
1 b
1 c
16 a
16 b
16 c
等...
所以基本上每个左手栏都选择那个和每个右手栏
由于 丹尼尔
答案 0 :(得分:5)
SELECT *
FROM Apples
CROSS JOIN
Oranges
或使用隐式连接语法,只需:
SELECT *
FROM Apples, Oranges
答案 1 :(得分:5)
这是简单的交叉连接
SELECT * FROM Apples, Oranges;
或
SELECT * FROM Apples CROSS JOIN Oranges;
答案 2 :(得分:0)
谢谢你们!
老板为我回答了一个模拟:
Select A.Apple,P.Peach From
(
Select 1 As Apple
Union
Select 2 As Apple
Union
Select 3 As Apple
Union
Select 4 As Apple
Union
Select 5 As Apple
Union
Select 6 As Apple
) A
Cross Join
(
Select 'a' As Peach
Union
Select 'b'
Union
Select 'c'
Union
Select 'd'
Union
Select 'e'
) P