From: | Rafal Pietrak <rafal(at)ztk-rp(dot)eu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: partial JOIN (was: ID column naming convention) |
Date: | 2015-10-24 19:42:37 |
Message-ID: | 562BDF2D.6010902@ztk-rp.eu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
W dniu 24.10.2015 o 21:03, Rafal Pietrak pisze:
>
>
> W dniu 24.10.2015 o 15:00, David G. Johnston pisze:
>> On Sat, Oct 24, 2015 at 6:41 AM, Rafal Pietrak <rafal(at)ztk-rp(dot)eu
>> <mailto:rafal(at)ztk-rp(dot)eu>>wrote:
> [----------------------]
>>
>> Using explicit column names is expected - using "*" in non-trivial and
>> production queries is not.
>>
>> You can move the aliases if you would like.
>>
>> SELECT *
>> FROM tablea (col1, col2, col4)
>> JOIN tableb AS tb1 (col1, col3, col5) USING (col1)
>> JOIN tableb AS tb2
>>
>> (col1, col6, col7) USING (col1)
>
> I knew there must have been something like this.
Upss. Almost, but not quite. I've just read the manual on that
(http://www.postgresql.org/docs/9.4/static/queries-table-expressions.html)
and it looks like "col1", "col2", etc in the above example are column
*aliases*. Right?
So I have to list *all* the columns of the aliased table irrespectively
if I need any of them within the output, or not.
It's a pity standard didn't choose to make column aliasing optional,
allowing for cherry pick what's aliased like following:
.. JOIN table AS tb(column7 [as alias1], column3 [as alias2],...)
thenx anyway, "Mandatory" column aliasing is helpfull too.
-R
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2015-10-24 19:45:12 | Re: Duplicate rows during pg_dump |
Previous Message | Lele Gaifax | 2015-10-24 19:37:57 | Re: Using function returning multiple values in a select |