Link to home
Start Free TrialLog in
Avatar of rkeith2412
rkeith2412Flag for United States of America

asked on

MySQL complex update

Ok, let's see if I can expalin what I want.  Basically I have three tables called record, records, and users.  I am migrating data from record to records which is layed out a little better with less data being duplicated.

I need to read users.id where record.supEmpNum = users.empNum and update records.supID with the returned data where record.id = records.id
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

is this a UPDATE or a INSERT?

assuming it's a UPDATE, consider reading this article that explains, though not for MySQL alone, how to build up the UPDATES with JOINS:
https://www.experts-exchange.com/articles/Database/Miscellaneous/UPDATES-with-JOIN-for-everybody.html
Avatar of rkeith2412

ASKER

I am looking to update, I already have an insert using the same field in the users table.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yes I did, I had moved on to the syntax of the update statement at http://dev.mysql.com/doc/refman/5.0/en/update.html
I was really close, thanks for the help.
I put a syntax suggestion above also, which should help also.