Re: [GENERAL] Fields re-ordered on JOIN with * and USING

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [GENERAL] Fields re-ordered on JOIN with * and USING
Дата
Msg-id 5617.1504314270@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [GENERAL] Fields re-ordered on JOIN with * and USING  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Fri, Sep 1, 2017 at 2:25 PM, Ken Tanzer <ken.tanzer@gmail.com> wrote:
>> Hi.  I recently noticed that when doing a SELECT * with USING, that the
>> join field(s) appear first in the output.  I'd never noticed that before,
>> and was just curious if that is expected behavior or not.  Thanks.

> ​I don't recall if or where it is documented but it is intentional., as is
> the documented fact that only one instance of the named column appears in
> the output.

Yes, it's documented, here:

https://www.postgresql.org/docs/current/static/queries-table-expressions.html#QUERIES-FROM

under "7.2.1.1. Joined Tables":

    Furthermore, the output of JOIN USING suppresses redundant columns:
    there is no need to print both of the matched columns, since they must
    have equal values. While JOIN ON produces all columns from T1 followed
    by all columns from T2, JOIN USING produces one output column for each
    of the listed column pairs (in the listed order), followed by any
    remaining columns from T1, followed by any remaining columns from T2.

            regards, tom lane


В списке pgsql-general по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: [GENERAL] Fields re-ordered on JOIN with * and USING
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [GENERAL] Fields re-ordered on JOIN with * and USING