Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.58 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. SQL query to check whether the values are same in two tables
  2. spsscode  spssdescription   brpcode    brpdescripton
  3.  
  4. 1         cash deposit      x          cash deposit
  5. 7         withdraw          y          withdraw
  6. 8         cheque deposit    w          cheque deposit
  7. 9         bank transfer     v          bank transfer
  8.        
  9. select spsscode, spssdescription, brpcode, brpdescripton, min(which_table)
  10. from
  11. (select t.*, 'old' which_table from oldtable t
  12.  union all
  13.  select t.*, 'new' which_table from newtable t) v
  14. group by spsscode, spssdescription, brpcode, brpdescripton
  15. having count(*) < 2