Fields re-ordered on JOIN with * and USING

From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Fields re-ordered on JOIN with * and USING
Date: 2017-09-01 21:25:35
Message-ID: CAD3a31W0mJHWNuvec-NSSSFUbABwJFp=ued_UYUqAM3vbP0i5Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

Ken

CREATE TEMP TABLE t1 (
f1 INTEGER,
f2 INTEGER UNIQUE,
f3 INTEGER,
f4 INTEGER
);

CREATE TEMP TABLE t2 (
f2 INTEGER,
f3 INTEGER,
f5 INTEGER
);

SELECT * FROM t1 LEFT JOIN t2 USING (f3,f2);

f3 | f2 | f1 | f4 | f5
----+----+----+----+----
(0 rows)

--
AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ <http://agency-software.org/>*
*https://agency-software.org/demo/client
<https://agency-software.org/demo/client>*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801

Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Paul Linehan 2017-09-01 22:08:32 Strange SQL result - any ideas.
Previous Message Bob Jones 2017-09-01 21:17:07 Re: Issue with json_agg() and ordering