pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: CoL <col@mportal.hu>
To: pgsql-sql@postgresql.org
Subject: Re: Subqueries returning more than one value?
Date: Tue, 11 May 2004 03:43:29 +0200
Message-ID: <c7pb0g$690$1@news.hub.org> (raw)
In-Reply-To: <BCC5D84E.32817%awitney@sghms.ac.uk>
References: <BCC5D84E.32817%awitney@sghms.ac.uk>

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.



view thread (2+ messages)

Message-ID: <c7pb0g$690$1@news.hub.org>
Permalink:  ../c7pb0g$690$1@news.hub.org/
Also on:    postgresql.org/message-id/c7pb0g$690$1@news.hub.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: col@mportal.hu
  Subject: Re: Subqueries returning more than one value?
  In-Reply-To: <c7pb0g$690$1@news.hub.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox