Skip to content

Instantly share code, notes, and snippets.

@Kcko
Created August 31, 2017 09:37
Show Gist options
  • Select an option

  • Save Kcko/23d64fdea0ceadf4c568b4b09edec84e to your computer and use it in GitHub Desktop.

Select an option

Save Kcko/23d64fdea0ceadf4c568b4b09edec84e to your computer and use it in GitHub Desktop.
Mysql update join
UPDATE table A
JOIN table B ON {join fields}
JOIN table C ON {join fields}
JOIN {as many tables as you need}
SET A.column = {expression}
Example:
UPDATE person P
JOIN address A ON P.home_address_id = A.id
JOIN city C ON A.city_id = C.id
SET P.home_zip = C.zipcode;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment