update query on multiple tables
Posted
by jon
on Stack Overflow
See other posts from Stack Overflow
or by jon
Published on 2010-03-08T04:59:22Z
Indexed on
2010/03/08
5:06 UTC
Read the original article
Hit count: 444
I have a schema like :
- employees (eno, ename, zip, hdate)
- customers (cno, cnmae, street, zip, phone)
- zipcodes (zip, city)
where zip is pk in zipcodes and fk in other tables.
I have to write an update query which updates all the occurence of zipcode 4994 to 1234 throughout the database.
update zipcodes,customers,employees
set zip = 0
where customers.zip = zipcodes.zip
and employees.zip = zipcodes.zip;
but i know i am not doing it right. Is there a way to update all the tables zip ina single update query?
© Stack Overflow or respective owner