Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Verwenden von Union All und Order By in MySQL

Verpacken Sie es in einer Unterabfrage.

SELECT s.*
FROM
    (
        SELECT  ap.*, 'advertised'  as type 
        FROM advertised_products as ap
          union all
        SELECT  wp.*, 'wanted' as type 
        FROM wanted_products as wp
    ) s
ORDER BY s.timestamp desc 
limit 3