From: | "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com> |
---|---|
To: | "Sam Mason" <sam(at)samason(dot)me(dot)uk> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Full outer join? Cross product? How to blend two queries into single row? |
Date: | 2008-09-04 21:26:39 |
Message-ID: | dcc563d10809041426o7ebe327fx6837cc3934bb4387@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Sep 4, 2008 at 3:22 PM, Sam Mason <sam(at)samason(dot)me(dot)uk> wrote:
> On Thu, Sep 04, 2008 at 03:43:33PM -0500, D. Dante Lorenso wrote:
>> I came up with this query that works, but seems overly complicated:
>>
>> SELECT a.col1, a.col2, b.col3, b.col4
>> FROM
>> (SELECT col1, col3, TRUE AS join_column
>> FROM mytable
>> WHERE uid = 'abc') a
>> FULL OUTER JOIN
>> (SELECT col3, col4, TRUE AS join_column
>> FROM mytable
>> WHERE uid = 'def') b
>> ON (a.join_column = b.join_column);
>>
>> Is this how to do it, or is there a simpler syntax I'm missing?
>
> The "ON" clause is just a normal expression, so you can just put a
> "TRUE" in there if you want a cross join. I.e. the following is a
> minimal full outer cross join:
>
> SELECT * FROM foo FULL OUTER JOIN bar ON TRUE;
can't you just drop the on clause altogether?
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Broersma | 2008-09-04 21:28:04 | Re: Full outer join? Cross product? How to blend two queries into single row? |
Previous Message | Sam Mason | 2008-09-04 21:22:16 | Re: Full outer join? Cross product? How to blend two queries into single row? |