How to copy value between tables

From: Michael Rowan <mike(dot)rowan(at)internode(dot)on(dot)net>
To: postgresql novice <pgsql-novice(at)postgresql(dot)org>
Subject: How to copy value between tables
Date: 2009-08-26 13:40:35
Message-ID: FD26DAF7-9E4B-47F2-A9AD-7E3DE1AFAC0B@internode.on.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Will the following work?

UPDATE child SET child_name = (SELECT parent_name FROM parent WHERE
parent_id = child_parent_id) WHERE child_name = 'not known' ;

That is, copy the parent_name into the corresponding child_name if the
child_name was 'not known'

Michael Rowan
mike(dot)rowan(at)internode(dot)on(dot)net

11 Kingscote Street
ALBERTON
South Australia 5014

tel 618 8240 3993

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Oliveiros C, 2009-08-26 13:53:21 Re: How to copy value between tables
Previous Message Jignesh Shah 2009-08-26 11:27:16 Re: compilation error