I want to perform a cartesian product between two SELECT statements as
SELECT 1, 2 INNER JOIN SELECT 3, 4 ;
I expect the result to
mysql> select * from
-> (select 1 x union select 2 union select 3 union select 4) t
-> join
-> (select 1 y union select 2 union select 3) tt;
+---+---+
| x | y |
+---+---+
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
| 2 | 1 |
| 2 | 2 |
| 2 | 3 |
| 3 | 1 |
| 3 | 2 |
| 3 | 3 |
| 4 | 1 |
| 4 | 2 |
| 4 | 3 |
+---+---+
12 rows in set (0.00 sec)
Removing the word join gives exactly the same result.
select * from
(select 1 x union select 2 union select 3 union select 4) t,
(select 1 y union select 2 union select 3) tt;