SQL Query to order 2 different tables with a similar attribute

I’ve 2 tables, they both have a structure similar to this one

id | content | date

However I would like to a make a query where the 2 tables are mixed together and ordered by their date

for example in the TABLE_A I’ve (1,Joe,20-11-2020)/(2,John,20-11-2021) TABLE_B has (1,Luke,20-11-2010)/(1,Mark,20-11-2011) The result I want to see is: (1,Luke,20-11-2010)/(1,Mark,20-11-2011)/(1,Joe,20-11-2020)/(2,John,20-11-2021)

>Solution :

 SELECT T.ID,T.CONTENT,T.DATE
 FROM TABLE_1 AS T
   UNION ALL
 SELECT A.ID,A.CONTENT,A.DATE
 FROM TABLE_2 AS A
 ORDER BY 3

Leave a Reply