Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 1AADE2E2E6C for ; Sun, 27 Jan 2008 21:43:16 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 87629-03 for ; Sun, 27 Jan 2008 21:43:02 -0400 (AST) Received: from smtp-03.arnet.com.ar (smtp-03.arnet.com.ar [200.45.191.14]) by postgresql.org (Postfix) with SMTP id 9D24A2E2E65 for ; Sun, 27 Jan 2008 21:43:12 -0400 (AST) Received: (qmail 20795 invoked from network); 28 Jan 2008 01:41:08 -0000 Received: from unknown (HELO mail.marquesminen.com.ar) (190.137.128.83) by 0 with SMTP; 28 Jan 2008 01:41:08 -0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.marquesminen.com.ar (Postfix) with ESMTP id 1A0852773D; Sun, 27 Jan 2008 23:43:09 -0200 (ARST) X-Virus-Scanned: amavisd-new at example.com Received: from mail.marquesminen.com.ar ([127.0.0.1]) by localhost (linus.marques [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8yHagJJvA6r3; Sun, 27 Jan 2008 23:43:06 -0200 (ARST) Received: from [192.168.0.5] (dagobah.marques [192.168.0.5]) by mail.marquesminen.com.ar (Postfix) with ESMTP id AC7C0275F3; Sun, 27 Jan 2008 23:43:06 -0200 (ARST) Message-ID: <479D3328.50903@marquesminen.com.ar> Date: Sun, 27 Jan 2008 23:43:04 -0200 From: Martin Marques User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: Bryce Nesbitt CC: pgsql-sql@postgresql.org Subject: Re: Syntax question: use of join/using with fully qualified table name References: <479D2694.3090202@obviously.com> In-Reply-To: <479D2694.3090202@obviously.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200801/207 X-Sequence-Number: 30060 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.