SQL: How To Display & Compare 2 Query Results In The Same Window


/ Published in: SQL
Save to your folder(s)

This is how to run 2 separate queries and display them in the same window in order to compare the results.

You need to add the union all in between the queries. Then add a comma and null to the second query.


Copy this code and paste it in your HTML
  1. SELECT * FROM table1
  2.  
  3. UNION ALL
  4.  
  5. SELECT * FROM table2
  6.  
  7.  
  8. // ----------------
  9. IF one TABLE has more COLUMNS than the other, THEN IN the TABLE WITH the fewer COLUMNS, ADD ,NULL TO the END OF the SELECT statement TO ADD COLUMNS TO the results. ADD AS many ",null"s AS you need TO MATCH the NUMBER OF COLUMNS TO the other TABLE.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.