Link to home
Create AccountLog in
Avatar of Jay Roy
Jay RoyFlag for United States of America

asked on

update two tables

hi guys

is there anyway i can update two tables in one update query

UPDATE table1, table2
           SET table1.id = my_id
             ,  table2.name = my_name
             
         WHERE table1.id = passed_id;

a quick response is greatly appreciated

THanks
ASKER CERTIFIED SOLUTION
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account

Alternately, you could create an "after update" trigger on the first table that automatically updates the second table when the first one is updated.

That's probably more work than it's worth, but it is somewhat guaranteed to keep the two tables in sync.

HTH,
DaveSlash
Avatar of Jay Roy

ASKER

sorry daveslash, couldnt assign you points, saw your comments later.

thanks both.
anyhelp greatly appreciated
https://www.experts-exchange.com/questions/27435874/update-column-value-if-column-value-is-not-empty-or-null.html