Skip to content

Instantly share code, notes, and snippets.

@adamjforster
Created July 29, 2010 15:24
Show Gist options
  • Save adamjforster/498411 to your computer and use it in GitHub Desktop.
Save adamjforster/498411 to your computer and use it in GitHub Desktop.
Example SQL update statements using a join for PostgreSQL and MySQL.
/* PostgreSQL */
UPDATE a
SET a.b_id = b.id
FROM b
WHERE a.b_name LIKE b.name;
/* MySQL */
UPDATE a, b
SET a.b_id = b.id
WHERE a.b_name LIKE b.name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment