From: | Khangelani Gama <kgama(at)argility(dot)com> |
---|---|
To: | Sim Zacks <sim(at)compulab(dot)co(dot)il>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Correct update statement |
Date: | 2014-05-15 09:22:16 |
Message-ID: | 913a823d20fe37e52a57ab6f6c178aa9@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thank very much
*From:* pgsql-general-owner(at)postgresql(dot)org [mailto:
pgsql-general-owner(at)postgresql(dot)org] *On Behalf Of *Sim Zacks
*Sent:* Thursday, May 15, 2014 10:42 AM
*To:* pgsql-general(at)postgresql(dot)org
*Subject:* Re: [GENERAL] Correct update statement
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 null)
b
where contacts.con_id=b.con_id
On 05/15/2014 09:19 AM, Khangelani Gama wrote:
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
example using the first of the results below: I need take set addr_id (in
contact table) to 187479 where cus_acno = 243492 and con_id = 119360
Example:
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 null;
cus_acno | con_id | addr_id
----------+--------+---------
243492 | 119360 | 187479
393701 | 119824 | 458532
388538 | 118413 | 453178
Thanks
CONFIDENTIALITY NOTICE
The contents of and attachments to this e-mail are intended for the
addressee only, and may contain the confidential
information of Argility (Proprietary) Limited and/or its subsidiaries.
Any review, use or dissemination thereof by anyone
other than the intended addressee is prohibited.If you are not the
intended addressee please notify the writer immediately
and destroy the e-mail. Argility (Proprietary) Limited and its
subsidiaries distance themselves from and accept no liability
for unauthorised use of their e-mail facilities or e-mails sent other
than strictly for business purposes.
CONFIDENTIALITY NOTICE
The contents of and attachments to this e-mail are intended for the addressee only, and may contain the confidential
information of Argility (Proprietary) Limited and/or its subsidiaries. Any review, use or dissemination thereof by anyone
other than the intended addressee is prohibited.If you are not the intended addressee please notify the writer immediately
and destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries distance themselves from and accept no liability
for unauthorised use of their e-mail facilities or e-mails sent other than strictly for business purposes.
From | Date | Subject | |
---|---|---|---|
Next Message | Dorian Hoxha | 2014-05-15 13:39:39 | Re: are analyze statistics synced with replication? |
Previous Message | Sim Zacks | 2014-05-15 08:42:15 | Re: Correct update statement |