views:

37

answers:

3

Hello,

I am currently looking for a Select statement which will do this..

|------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

etc...

So basically for every left hand column select that and every right hand column

Thanks Daniel

+4  A: 
SELECT  *
FROM    Apples
CROSS JOIN
        Oranges

or, using implicit join syntax, just that:

SELECT  *
FROM    Apples, Oranges
Quassnoi
+4  A: 

This is simple cross join

SELECT * FROM Apples, Oranges;

or

SELECT * FROM Apples CROSS JOIN Oranges;
Vash
A: 

Thanks guys!

The Boss Answered it for me heres a simulation:

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
Daniel Upton
It is funny your solution does not match the exact question you asked. :)
Johann Blais
Haha i know.. but its close enough! ;)
Daniel Upton