Reputation: 513
I have two tablee.
Table A
ID
A001
A002
A003
Table B
COUNTRY
UK
USA
GERMANY
CHINA
I'd like to list all posible combination from each ID
and each CONTRY
My expected result should be:
A001 UK
A001 USA
A001 GERMANY
A001 CHINA
A002 UK
A002 USA
A002 GERMANY
A002 CHINA
A003 UK
A003 USA
A003 GERMANY
A003 CHINA
Upvotes: 0
Views: 45
Reputation: 14228
You can use Cross Join
to resolve it, Read @Sarath Avanavu's answer in this link to have a better understanding.
SELECT a.ID, b.COUNTRY
FROM TABLE a
Cross Join TABLE b
Upvotes: 1
Reputation: 522396
You may use a CROSS JOIN
here. Note for completeness that in MySQL, an inner join without any join criteria behaves like a cross join. So, we could actually try:
SELECT a.ID, b.COUNTRY
FROM TableA a
INNER JOIN TableB b
ORDER BY a.ID, b.COUNTRY;
Upvotes: 1
Reputation: 13016
this is just cross join
.
select * from tableA t1
cross join tableB
order by t1.ID
Upvotes: 1