I need to generate a SQL query for the following case:
First table:
column1 |
---|
A |
B |
Second table:
column2 |
---|
1 |
2 |
3 |
4 |
I want to create a query so the result will be like this:
column1 | column2 |
---|---|
A | 1 |
A | 2 |
A | 3 |
A | 4 |
B | 1 |
B | 2 |
B | 3 |
B | 4 |
Appreciate any answer, thank you.
Use a cross join between the two tables:
SELECT t1.column1, t2.column2
FROM FirstTable t1
CROSS JOIN SecondTable t2
ORDER BY t1.column1, t2.column2;