Re: Syntax question: use of join/using with fully qualified table name

From: Martin Marques <martin(at)marquesminen(dot)com(dot)ar>
To: Bryce Nesbitt <bryce1(at)obviously(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Syntax question: use of join/using with fully qualified table name
Date: 2008-01-28 01:43:04
Message-ID: 479D3328.50903@marquesminen.com.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bryce Nesbitt escribió:
> 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?
>
> select username,last_name from eg_member join eg_membership using
> (member_id) join eg_account using (account_id) join eg_person using
> (eg_member.person_id);
> ERROR: syntax error at or near "." at character 145

Did you read the manual?

USING (join_column [, ...])

A clause of the form USING ( a, b, ... ) is shorthand for ON
left_table.a = right_table.a AND left_table.b = right_table.b .... Also,
USING implies that only one of each pair of equivalent columns will be
included in the join output, not both.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2008-01-28 01:45:17 Re: Syntax question: use of join/using with fully qualified table name
Previous Message Bryce Nesbitt 2008-01-28 00:49:24 Syntax question: use of join/using with fully qualified table name