From: | "Thomas T(dot) Thai" <tom(at)minnesota(dot)com> |
---|---|
To: | Oliver Elphick <olly(at)lfix(dot)co(dot)uk> |
Cc: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: UPDATE with value from another table |
Date: | 2002-03-02 06:29:20 |
Message-ID: | Pine.NEB.4.43.0203020028250.28485-100000@ns01.minnesota.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2 Mar 2002, Oliver Elphick wrote:
> On Sat, 2002-03-02 at 05:08, Thomas T. Thai wrote:
> > UPDATE [ ONLY ] table SET col = expression [, ...]
> > [ FROM fromlist ]
> > [ WHERE condition ]
> >
> > Is this valid:
> >
> > UPDATE table1
> > SET col = table2.col
> > FROM table2
> > WHERE col = table2.id;
>
> Yes, in principle:
>
> junk=# UPDATE table1
> junk-# SET col = table2.col
> junk-# FROM table2
> junk-# WHERE col = table2.id;
> ERROR: Column reference "col" is ambiguous
>
> WHERE table2.col = table1.id;
right after i emailed the message, i tried it on a large dataset. works.
only gotcha is to drop any unique index first.
--
Thomas T. Thai
Minnesota.com, Inc.
From | Date | Subject | |
---|---|---|---|
Next Message | Patrick L. Nolan | 2002-03-02 07:55:38 | Defined C function gives nondeterministic results |
Previous Message | Francisco Reyes | 2002-03-02 06:23:59 | Re: Is vacuum full lock like old's vacuum's lock? |