-1

I have two tables identical to each other like below

table 1

col1
1
2
3
4
5

table 2

col1
1
2
3
4
5

is there way to write a SQL query to join every row of table 1 to every row of table 2?

Mr. Jin
  • 79
  • 8

2 Answers2

5

Do you want a Cartesian product? If so, use cross join:

select t1.col1, t2.col2
from table1 t1 cross join
     table2 t2;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
0

It sounds like an inner join as they are identical tables:

select t1.col, t2.col, ...
from table t1
inner join t2 on t1.col = t2.col
Neeraj Agarwal
  • 1,059
  • 6
  • 5