babbloo
babbloo

Reputation: 1

SQL query to check whether the values are same in two tables

I got a table like this:

spsscode  spssdescription   brpcode    brpdescripton

1         cash deposit      x          cash deposit
7         withdraw          y          withdraw
8         cheque deposit    w          cheque deposit
9         bank transfer     v          bank transfer

here in front end of it, the input code is SPSS and it stores the information in the form of BRP CODE in database (as defined in table)

now i have got a new release where changes are not made to this table, so i have to write a query to check whether the new table in latest version is exactly same as old table or not (i.e 1 = x, 7 = y, 8 = w, 9 = v).

in a way that i can select spss code and brp code from old table and check them against these codes in new table

Upvotes: 0

Views: 262

Answers (1)

user359040
user359040

Reputation:

Try:

select spsscode, spssdescription, brpcode, brpdescripton, min(which_table)
from
(select t.*, 'old' which_table from oldtable t
 union all
 select t.*, 'new' which_table from newtable t) v
group by spsscode, spssdescription, brpcode, brpdescripton
having count(*) < 2

Upvotes: 1

Related Questions