pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliveiros d'Azevedo Cristina <oliveiros.cristina@marktest.pt>
To: ssylla <stefansylla@gmx.de>
To: pgsql-sql@postgresql.org
Subject: Re: update column
Date: Fri, 10 Feb 2012 15:33:09 -0000
Message-ID: <3FD44D6D1A174424B961C819D298527A@marktestcr.marktest.pt> (raw)
References: <1328752685274-5468330.post@n5.nabble.com>

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

Doesn't it do what you want?

Best,
Oliveiros

----- Original Message ----- 
From: "ssylla" <stefansylla@gmx.de>
To: <pgsql-sql@postgresql.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@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql 




view thread (2+ messages)

Message-ID: <3FD44D6D1A174424B961C819D298527A@marktestcr.marktest.pt>
Permalink:  ../3FD44D6D1A174424B961C819D298527A@marktestcr.marktest.pt/
Also on:    postgresql.org/message-id/3FD44D6D1A174424B961C819D298527A@marktestcr.marktest.pt

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: oliveiros.cristina@marktest.pt, stefansylla@gmx.de
  Subject: Re: update column
  In-Reply-To: <3FD44D6D1A174424B961C819D298527A@marktestcr.marktest.pt>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox