Re: Basic SQL join question

From: "codeWarrior" <GPatnude(at)adelphia(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Basic SQL join question
Date: 2003-01-31 05:15:41
Message-ID: b1d0bn$1e63$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)mega-bucks(dot)co(dot)jp> wrote in message
news:3E39E8A8(dot)7020001(at)mega-bucks(dot)co(dot)jp(dot)(dot)(dot)
> 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2003-01-31 05:18:20 Re: grant to all tables
Previous Message Eric B.Ridge 2003-01-31 04:54:30 2D arrays in 7.3... actually, parser bug?