Select SQL from multiple tables with identical structure

mysql, sql

Solution

You can do it like this

SELECT * FROM (
                SELECT  * FROM table1
                UNION ALL
                SELECT  * FROM table2
                UNION ALL
                SELECT  * FROM table3   
) as l
ORDER BY id ASC LIMIT 50

UNION will only work when you have same number of columns in each table

Problem

``` SELECT * FROM table1, table2, table3 ORDER BY id ASC LIMIT ``` how to do this right? I'm using MySQL and all the tables have identical structure.

Original source