Compare record in two tables, return fields that don"t match...

Compare record in two tables, return fields that don"t match...

am 09.07.2007 15:59:14 von Nick

Does anyone know if there is an easy way to compare a row from table
a, to a row in table b with the same structure/field names and return
those fields which don't match?

I have table_a storing the originally submitted applicant information,
and table_b storing a version that can be changed. When a user makes a
change I'd like to compare it to the original table to see what fields
were changed, preferably without opening the row from both tables and
going field by field in code to see if they match...

Thank you for the help!

Nick Smith
Application Developer
Influent Inc.

Re: Compare record in two tables, return fields that don"t match...

am 09.07.2007 18:11:54 von Omar Langset

Nick wrote:
> Does anyone know if there is an easy way to compare a row from table
> a, to a row in table b with the same structure/field names and return
> those fields which don't match?
>
> I have table_a storing the originally submitted applicant information,
> and table_b storing a version that can be changed. When a user makes a
> change I'd like to compare it to the original table to see what fields
> were changed, preferably without opening the row from both tables and
> going field by field in code to see if they match...
>
> Thank you for the help!
>
> Nick Smith
> Application Developer
> Influent Inc.
>
This should work

select * from table_a a, table_b b where a.applicantId = b.applicantId
and ((a.row1 != b.row1) or (a.row2 != b.row2) or ..... )