If I understand your question correctly, this is one of those rare cases where a CROSS JOIN
is actually what you want. A CROSS JOIN
will give you the Cartesian product of two sets, which means all possible combinations between the values in those sets.
Example:
- Table A with column 1 contains values 'a' and 'b'
- Table B with column 2 contains values 'c' and 'd'
The following CROSS JOIN
query (note there is no 'join condition' specified, on purpose):
SELECT *
FROM A
CROSS JOIN B
will return the following result:
1 2
--------
a c
a d
b c
b d
I created an SQL Fiddle to show you a possible solution. You can tweak it a bit to see if this is what you need. (Note it's an Oracle fiddle, as there is no DB2 option.)