Skip site navigation (1) Skip section navigation (2)

Re: select & insert

From: Arcady Genkin <a(dot)genkin(at)utoronto(dot)ca>
To: pgsql-novice(at)postgreSQL(dot)org, Mauricio Alarcon <malarcon(at)webdepot(dot)com(dot)co>
Subject: Re: select & insert
Date: 2000-12-20 18:33:28
Message-ID: 8766kfkknb.fsf@tea.thpoon.com (view raw or flat)
Thread:
Lists: pgsql-novice
Mauricio Alarcon <malarcon(at)webdepot(dot)com(dot)co> writes:

> How I can make an update to a register from a select query?
> I have this
> 
> update table1 set r1=(select r1+1 from table1);

Try this:

update table1 set r1=(select T1.r1+1 from table1 T1);

Note that if there is more than one row in the table1, then you might
want to limit the select clause by some condition.
-- 
Arcady Genkin
Don't read everything you believe.

In response to

pgsql-novice by date

Next:From: Wayne JohnsonDate: 2000-12-20 18:36:31
Subject: Java vs. PHP (was web interface for postgreSQL-P.S.)
Previous:From: Karla PeraltaDate: 2000-12-20 16:48:59
Subject: Speed

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group