Re: Subqueries in Non-SELECT Queries

Поиск
Список
Период
Сортировка
От Christof Glaser
Тема Re: Subqueries in Non-SELECT Queries
Дата
Msg-id 00121719325000.15220@pinguin
обсуждение исходный текст
Ответ на Subqueries in Non-SELECT Queries  (Frank Joerdens <frank@joerdens.de>)
Список pgsql-sql
Frank Joerdens wrote:

> mpi=# update index set level = 2 where parentid = ( select id from
> index where level = 1 );
> ERROR:  More than one tuple returned by a subselect used as an
> expression. mpi=#
>
> This is a recursive query, on a single table. Is that not possible?

Hi Frank,

as the error message says, the subselect must return only one value,
since the where clause compares just one field for equality. You might 
try IN instead of =, ie

update index set level = 2 where parentid in ( select id from
index where level = 1 );

Hope that helps.

Christof
--          gl.aser . software engineering . internet service      http://gl.aser.de/  . Planckstraße 7 . D-39104
Magdeburg
Tel. +49.391.7 44 77 10 . Fax +49.391.7 44 77 13 . Mobil 0177.77 92 84 3


В списке pgsql-sql по дате отправления:

Предыдущее
От: Frank Joerdens
Дата:
Сообщение: Subqueries in Non-SELECT Queries
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Subqueries in Non-SELECT Queries