Posted By

heathbo on 09/30/14


Tagged


Versions (?)

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


 / Published in: SQL
 

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.

  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  

You need to login to post a comment.