Page 1 of 1

Updating multiple tables

Posted: Fri Aug 04, 2006 3:18 am
by Benjamin
Is there a way to perform an update on more than 1 table at a time? Something similar to a JOIN?

Code: Select all

update tableOne set tableOne.this=blah, tableTwo.that=blah
    join tabletwo on tableOne.x = tableTwo.x
    where tableOne.id = 5

Posted: Fri Aug 04, 2006 3:44 am
by GM
Yes:

Code: Select all

UPDATE table_one a, table_two b 
SET a.field1 = 'value',
b.field1 = 'value'
WHERE a.id = 'this'
AND b.id = 'that';

Posted: Fri Aug 04, 2006 3:59 am
by Benjamin
Thank you!!