pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bryce Nesbitt <bryce1@obviously.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Syntax question: use of join/using with fully qualified table name
Date: Sun, 27 Jan 2008 20:45:17 -0500
Message-ID: <16133.1201484717@sss.pgh.pa.us> (raw)
In-Reply-To: <479D2694.3090202@obviously.com>
References: <479D2694.3090202@obviously.com>

Bryce Nesbitt <bryce1@obviously.com> writes:
> I've got a join where a certain column name appears twice:
> select username,last_name from eg_member join eg_membership using
> (member_id) join eg_account using (account_id) join eg_person using
> (person_id);
> ERROR:  common column name "person_id" appears more than once in left table

> My first inclination was to fully quality the table name.  Why would
> this not be acceptable syntax?

Because USING is defined as joining common column names.  It is driven
entirely by the column names, not any "qualification", and it needs to
have well-defined behavior.  The SQL92 spec saith

         <named columns join> ::=
              USING <left paren> <join column list> <right paren>

         <join column list> ::= <column name list>

         <column name list> ::=
              <column name> [ { <comma> <column name> }... ]

         <column name> ::= <identifier>

         ...

            b) If a <named columns join> is specified, then every <column
              name> in the <join column list> shall be the <column name>
              of exactly one column of T1 and the <column name> of exactly
              one column of T2.

			regards, tom lane



view thread (3+ messages)

Message-ID: <16133.1201484717@sss.pgh.pa.us>
Permalink:  ../16133.1201484717@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16133.1201484717@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, bryce1@obviously.com
  Subject: Re: Syntax question: use of join/using with fully qualified table name
  In-Reply-To: <16133.1201484717@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox