How do I combine the results of two queries with ordering?

前端 未结 2 1737
走了就别回头了
走了就别回头了 2020-12-15 07:11

How do you join the results of 2 queries, ordering by date?

SELECT * FROM table1 WHERE tag=\'1\'
SELECT * FROM table2 WHERE tag=\'3\'

table

2条回答
  •  太阳男子
    2020-12-15 07:29

    SELECT * 
    FROM   (SELECT * 
            FROM   table1 
            UNION 
            SELECT * 
            FROM   table2) t 
    ORDER  BY t.DATE 
    

提交回复
热议问题