Posted By

lottegis on 08/18/14


Tagged


Versions (?)

Compare table difference


 / Published in: SQL
 

Example below

  1. --1. Find what's present in table A.
  2. --Syntax
  3.  
  4. SELECT A.*
  5. FROM A LEFT JOIN B ON (A.C = B.C)
  6. WHERE B.C IS NULL;
  7.  
  8.  
  9. --Example
  10. SELECT NEW.*
  11. FROM AlbertaData.SWG_650s20130312 AS NEW
  12. LEFT JOIN AlbertaData.SWG_650s20130101 AS OLD
  13. ON (NEW.OBJECTID = OLD.OBJECTID)
  14. WHERE OLD.OBJECTID IS NULL;
  15.  
  16.  
  17.  
  18. --2. Find all the differences between tables:
  19. --Syntax
  20.  
  21. SELECT A.*, B.*
  22. FROM A FULL JOIN B ON (A.C = B.C)
  23. WHERE A.C IS NULL OR B.C IS NULL;

Report this snippet  

You need to login to post a comment.