Re: update syntax

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: chester c young <chestercyoung(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: update syntax
Date: 2002-01-27 03:40:07
Message-ID: 200201270340.g0R3e7813150@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

chester c young wrote:
> thanks, but how would this be done for the same table?
>
> update table1 t1 set (c2, c3 ) =
> ( select c2, c3 from table1 t2 where t1.c1 = t2.c1 and t1.oid < t2.oid
> );

In that 'FROM c1 c2', c2 was a table alias for table c1. That is how
you get the second instance of c1.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2002-01-27 03:59:15 Re: LIMIT Optimization
Previous Message chester c young 2002-01-27 02:59:07 Re: update syntax