Thread: How to copy value between tables

How to copy value between tables

From
Michael Rowan
Date:
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.rowan@internode.on.net

11 Kingscote Street
ALBERTON
South Australia 5014

tel 618 8240 3993




Re: How to copy value between tables

From
"Oliveiros C,"
Date:
Howdy, Michael.

I didnt try your query, but at first glance, it seems OK, why do you ask?

Did you try and it gave u some kind of error?

Best,
Oliveiros

----- Original Message -----
From: "Michael Rowan" <mike.rowan@internode.on.net>
To: "postgresql novice" <pgsql-novice@postgresql.org>
Sent: Wednesday, August 26, 2009 2:40 PM
Subject: [NOVICE] How to copy value between tables


> 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.rowan@internode.on.net
>
> 11 Kingscote Street
> ALBERTON
> South Australia 5014
>
> tel 618 8240 3993
>
>
>
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice