Friday, June 10, 2011

UPDATE SELECT FROM JOIN

This is something that I don't do often, but it pops up every now and again. I always forget how to do it, so I have to look it up each time.

Here is an example:

UPDATE alias
SET
 col1 = value,
 col2 = value,
 col3 = value
FROM table1 alias
 INNER JOIN table2 blah
  ON alias.pk = blah.pk
WHERE otherconditions

No comments:

Post a Comment