pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
update column
2+ messages / 2 participants
[nested] [flat]

* update column
@ 2012-02-09 01:58  ssylla <stefansylla@gmx.de>
  0 siblings, 1 reply; 2+ messages in thread

From: ssylla @ 2012-02-09 01:58 UTC (permalink / raw)
  To: pgsql-sql

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.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: update column
@ 2012-02-10 15:33  Oliveiros d'Azevedo Cristina <oliveiros.cristina@marktest.pt>
  parent: ssylla <stefansylla@gmx.de>
  0 siblings, 0 replies; 2+ messages in thread

From: Oliveiros d'Azevedo Cristina @ 2012-02-10 15:33 UTC (permalink / raw)
  To: ssylla <stefansylla@gmx.de>; pgsql-sql

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 




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2012-02-10 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-02-09 01:58 update column ssylla <stefansylla@gmx.de>
2012-02-10 15:33 ` Oliveiros d'Azevedo Cristina <oliveiros.cristina@marktest.pt>

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