简体   繁体   中英

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. Ie 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

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

UNION ALL allows duplicates.

Whereas UNION removes duplicates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM