SearchSearch   

Compare record in two tables, return fields that don't mat..

 
   Webmaster Forums (Home) -> MySQL RSS
Next:  Simple MySQL Index  
Author Message
Nick

External


Since: Jul 09, 2007
Posts: 1



(Msg. 1) Posted: Mon Jul 09, 2007 6:59 am
Post subject: Compare record in two tables, return fields that don't match...
Archived from groups: mailing>database>mysql (more info?)

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.
Back to top
Omar Langset

External


Since: Jul 09, 2007
Posts: 1



(Msg. 2) Posted: Mon Jul 09, 2007 6:11 pm
Post subject: Re: Compare record in two tables, return fields that don't match...
Archived from groups: per prev. post (more info?)

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 ..... )
Back to top
Display posts from previous:   
       Webmaster Forums (Home) -> MySQL
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum