Untitled UI logotext
Solutions
WebsitesEcommerceMobile AppsWeb AppsProduction Support & Maintenance
Our work
Company
About usBlogPodcastContact us
Book a free consultation

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

Olivia Rhye

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`
SET
`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.

Ready to start a project?

Book a free consultation
Untitled UI logotext
Our work
About us
Blog
Careers
Submit a ticket
Agency Partnerships
Contact
© 2024 fjorge. All rights reserved.
Privacy