confused how to achieve this maybe with FULL OUTER or a UNION. I want to join results in such a way that
Table1 Table2
--------------- -----------------
ID Name Salary ID Fruits
--------------- -----------------
1 John 1000 1 Apples
1 Henry 4000 1 Mangoes
1 Smith 1000 1 Tomatoes
Result should be
ResultTable
------------------------
ID Name Salary Fruits
-----------------------
1 John 1000 Apples
1 John 1000 Mangoes
1 John 1000 Tomatoes
1 Henry 4000 Apples
1 Henry 4000 Mangoes
1 Henry 4000 Tomatoes
1 Smith 1000 Apples
1 Smith 1000 Mangoes
1 Smith 1000 Tomatoes
You need a cartesian product join or Cross Join ..
SELECT
*
FROM
table1, table2
or
SELECT
*
FROM
table1 CROSS JOIN table2
(reference: http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/sqlp/rbafymstcrojo.htm)
use cross join
if db2 has it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With