Currently, I'm working on a project that requires me to execute 2 SQL queries, then I have to sort the output by date and id before writing the output of both queries to a table.
Sorting both queries in SQL with :
ORDER BY order.date DESC, order.id DESC.
Try to use
SELECT A.* FROM ((QUERY1) UNION ALL (QUERY2)) A ORDER BY A.date DESC, A.id DESC