Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading