What is it actually that you want?
- A Cartesian Product of the two tables
- All rows of the first table, and all rows of the second table?
I put some sample data in the WITH clause (yes, the WITH keyword only once, then a comma list), and show the two results. Yours, first (and I concur with @GMB that you should use CROSS JOIN
if you join two tables with no filter), and then what I think would make more sense .
Here goes.
-- the WITH clause ...
WITH
table1(id,something) AS (
SELECT 11,'something 1 from 1'
UNION ALL SELECT 12,'something 2 from 1'
UNION ALL SELECT 13,'something 3 from 1'
)
,
table2(id,something) AS (
SELECT 21,'something 1 from 2'
UNION ALL SELECT 22,'something 2 from 2'
UNION ALL SELECT 23,'something 3 from 2'
)
-- then, I select from this, as you would - with the result you'd get:
SELECT * FROM table1,table2
id | something | id | something
----+--------------------+----+--------------------
11 | something 1 from 1 | 21 | something 1 from 2
12 | something 2 from 1 | 21 | something 1 from 2
13 | something 3 from 1 | 21 | something 1 from 2
11 | something 1 from 1 | 22 | something 2 from 2
12 | something 2 from 1 | 22 | something 2 from 2
13 | something 3 from 1 | 22 | something 2 from 2
11 | something 1 from 1 | 23 | something 3 from 2
12 | something 2 from 1 | 23 | something 3 from 2
13 | something 3 from 1 | 23 | something 3 from 2
-- and finally, what I am almost sure you should do:
SELECT * FROM table1 UNION ALL SELECT * FROM table2;
id | something
----+--------------------
11 | something 1 from 1
12 | something 2 from 1
13 | something 3 from 1
21 | something 1 from 2
22 | something 2 from 2
23 | something 3 from 2