Premi
Premi

Reputation: 13

SQL Match two tables

I've got the following Situation and maybe the is a more comfortable way for my Problem.

I got two tables (for Example ORDERS, CANCEL), each table got values and there is no way to join them.

Here are some records to understand what i want to do.

ORDERS:

1
2
3
4
5

CANCEL:

A
B
C
D
E

Now i need the following Output:

1  A
1  B
1  C
1  D
1  E
2  A
2  B
2  C
2  D
2  E
3  A

And so on. And maybe i need to match a thirth table. Anyone a Idea?

Upvotes: 1

Views: 46

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269663

You can use cross join:

select o.col1, c.col1
from orders o cross join
     cancels c;

Upvotes: 3

Related Questions