Re: update column

From: "Oliveiros d'Azevedo Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt>
To: "ssylla" <stefansylla(at)gmx(dot)de>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: update column
Date: 2012-02-10 15:33:09
Message-ID: 3FD44D6D1A174424B961C819D298527A@marktestcr.marktest.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

UPDATE admin
SET parent = SUBSTR(id,1,4);

Doesn't it do what you want?

Best,
Oliveiros

----- Original Message -----
From: "ssylla" <stefansylla(at)gmx(dot)de>
To: <pgsql-sql(at)postgresql(dot)org>
Sent: Thursday, February 09, 2012 1:58 AM
Subject: [SQL] update column

> Dear list,
>
> sorry, I already posted this, but it did not seem to have been accepted by
> the mailing list. So here's my second try:
>
> I need to update all rows of a column ('parent') based on a subquery that
> returns me the first four digits of another column ('id'):
>
> UPDATE admin SET parent=(SELECT SUBSTR(id,1,4) FROM admin);
>
>
> After executing, I get the following error-message:
>
> "more than one row returned by a subquery used as an expressionmore than
> one
> row returned by a subquery used as an expression"
>
>
> I am not quite sure about that, but maybe I need to construct a
> function/loop to fulfill this task?
>
> thanks for help.
>
> Stefan
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/update-column-tp5468330p5468330.html
> Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message David Johnston 2012-02-10 16:08:11 Re: update column with multiple values
Previous Message Igor Neyman 2012-02-10 14:41:38 Re: Concurrent Reindex on Primary Key for large table