Re: Subqueries returning more than one value?

From: CoL <col(at)mportal(dot)hu>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Subqueries returning more than one value?
Date: 2004-05-11 01:43:29
Message-ID: c7pb0g$690$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

hi,

Adam Witney wrote, On 5/11/2004 02:09:
> Hi,
>
> I am using a function in a subquery, this works ok:
>
> SELECT name, (SELECT p_my_func(1)) AS id
> FROM test;
>
> However I would like to have the function return 2 values into the main
> query... Something like this:
>
> SELECT name, (SELECT p_my_func(1)) AS (id, type)
> FROM test;
>
> Of course this gives the error:
>
> ERROR: subquery must return only one column
>
> Is there any way around this?

SELECT name,t.* FROM (SELECT p_my_func(1)) AS t(id, type), test

C.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andrei Bintintan 2004-05-11 06:02:19 Re: Exceptions when 0 rows affected.
Previous Message Adam Witney 2004-05-11 00:09:34 Subqueries returning more than one value?