Re: [GENERAL] Correct update statement

2014-05-15 Thread Khangelani Gama
Thank very much *From:* pgsql-general-ow...@postgresql.org [mailto: pgsql-general-ow...@postgresql.org] *On Behalf Of *Sim Zacks *Sent:* Thursday, May 15, 2014 10:42 AM *To:* pgsql-general@postgresql.org *Subject:* Re: [GENERAL] Correct update statement update contacts set addr_id=b.addr_id

Re: [GENERAL] Correct update statement

2014-05-15 Thread Sim Zacks
update contacts set addr_id=b.addr_id from (select distinct(cus_acno), contact.con_id, address.addr_id from address join person using (addr_id) join  cus using (per_id) join link_contact using (cus_acno) join contact using (con_id) where contact.addr_id is

[GENERAL] Correct update statement

2014-05-14 Thread Khangelani Gama
Hi Please help, we are using postgreSQL 9.2.4. I need to update over 9000 rows. See the query below: A table called contact has got *addr_id *field as null which is incorrect. So now I need to update contact table for each account (cus_acno is in cus table) where contact_addr_id is null. For ex