Re: Basic SQL join question - Mailing list pgsql-general

From codeWarrior
Subject Re: Basic SQL join question
Date
Msg-id b1d0bn$1e63$1@news.hub.org
Whole thread Raw
In response to Basic SQL join question  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
List pgsql-general
Here's an example using aggregates that's sort of close...

SELECT (SELECT COUNT(id) FROM cb_person_plan_enroll WHERE person_id = 72) AS
STDPLANS, (SELECT COUNT(id) FROM cb_person_pog_enroll WHERE person_id = 72)
AS POGPLANS, (SELECT COUNT(id) FROM cb_person_grp_enroll WHERE person_id =
72) AS GRPPLANS;

The problem is that if you dont need an aggregate and the tables nothing in
common to join on... you really can't go around joining them if there's
nothing to join....

Now -- if you were to create a cursor and select into it from the tables in
question... you might get somewhere...



"Jean-Christian Imbeault" <jc@mega-bucks.co.jp> wrote in message
news:3E39E8A8.7020001@mega-bucks.co.jp...
> Sorry for this simple question but I can't seem to get Postgres to do
> what I want ...
>
> I want to get the concatenation of 2 or more tables with absolutely
> nothing in common. How can I do this?
>
> For example
>
> Table a:
>
>    a
> -----
>   a1
>   a2
>   a3
>
> Table b:
>
>    b
> -----
>   b1
>   b2
>
> Table c:
>
>    c
> -----
>   c1
>   c2
>   c3
>   c4
>
> What is the proper SQL to return:
>
>    a |  b |  c
> ---------------
>   a1   b1   c1
>   a2   b2   c2
>   a3        c3
>             c4
>
>
> Thanks,
>
> Jc
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org



pgsql-general by date:

Previous
From: "Chris White"
Date:
Subject: FW: Duplicate indexes found in the postgres Database
Next
From: Jeff
Date:
Subject: Re: [PERFORM] One large v. many small