How do I do a JOIN in an UPDATE query with MySQL

August 18, 2011

As a follow up to my June 22nd post on doing a JOIN in an UPDATE with SQL Server, I just needed to do the same in MySQL. Here’s the syntax I used:

UPDATE `site_locations` 
LEFT JOIN `locations` ON `site_locations`.`location_id` = `locations`.`id`
`site_locations`.`location_phone` = `locations`.`adwizard_phone`, 
`site_locations`.`location_phone_ext` = `locations`.`adwizard_phone_ext` 
WHERE `site_locations`.`location_phone` IS NULL

As you can see, the order of things is a little different in MySQL vs SQL Server.

Stay in Touch!

Subscribe to our newsletter.

Solutions Architecture

browse through our blog articles

Blog Archive