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

update column with multiple values

From: ssylla <stefansylla(at)gmx(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: update column with multiple values
Date: 2012-02-09 02:31:19
Message-ID: 1328754679303-5468395.post@n5.nabble.com (view raw or flat)
Thread:
Lists: 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-with-multiple-values-tp5468395p5468395.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.

Responses

pgsql-sql by date

Next:From: Jasen BettsDate: 2012-02-09 11:36:57
Subject: Re: time interval math
Previous:From: ssyllaDate: 2012-02-09 01:58:05
Subject: update column

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