Petr
Petr

Reputation: 7957

MySQL> Selecting from more tables (with same columns) without UNION

It is probably pretty simple but I cannot figure it out: Say I have tables A and B both with the same columns. I need to do SELECT * FROM A,B without having results merged into one row. I.e. when each table has 2 rows, I need the result to have 4 rows.
EDIT: I know about JOIN but dont know how to join the tables without predicate. I need merge them. Thanks

Upvotes: 0

Views: 245

Answers (1)

mechanical_meat
mechanical_meat

Reputation: 169274

SELECT col1, col2 FROM A
UNION ALL
SELECT col1, col2 FROM B

UNION ALL allows duplicates.

Whereas UNION removes duplicates.

Upvotes: 2

Related Questions