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$1@news.hub.org (view raw or flat)
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

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-2014 The PostgreSQL Global Development Group