troubleshooting Question

updating record in mysql database

Avatar of RupertA
RupertAFlag for United Kingdom of Great Britain and Northern Ireland asked on
4 Comments2 Solutions223 ViewsLast Modified:
Hi, I was hoping somebody could help me out with some mysql or mysql/php if it needs it. I have two tables in a mysql database.

Table1 has two fields 1) userref 2) payroll
Table 2 has two fields 1) userID 2) payroll_number

userref & userID are the same thing - the person's username. And payroll & payroll_number are the same thing - the person's payroll number.

I want to run some mysql which does the following. I want to take the userID from table2 and find the corresponding userref in table1. In other words for userID "Rupert" there will be a userref "Rupert" in table 1. So for the corresponding record in table1 I want it to check if "payroll" is different to "payroll_number". If it is the same then it need not be changed. However if it is different, I want "payroll" to be updated with the corresponding "payroll_number".

Would be grateful if somebody could give me some code.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros