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

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$ (view raw, whole thread or download thread mbox)
Lists: pgsql-sql

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


In response to

pgsql-sql by date

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

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