Re: Can I unite 2 selects?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Sterpu Victor <victor(at)caido(dot)ro>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Can I unite 2 selects?
Date: 2015-01-29 19:09:31
Message-ID: 54CA856B.5060001@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 01/29/2015 10:58 AM, Sterpu Victor wrote:
> Hello
> Can I write a query where I receive a single result set from many queries?
> Something like this: SELECT (SELECT 1 AS t1, 2 AS t2), (SELECT 3 AS t3)
> I tried exactly this but the error is: "ERROR: subquery must return
> only one column"
> But I don't see why it must have only one column.

postgres(at)test=# SELECT * from (SELECT 1 AS t1, 2 AS t2) as t, (SELECT 3
AS t3) as s;
t1 | t2 | t3
----+----+----
1 | 2 | 3

> Thank you

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Edson Richter 2015-01-29 19:11:02 Re: Can I unite 2 selects?
Previous Message Sterpu Victor 2015-01-29 18:58:23 Can I unite 2 selects?