Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s8LbB-00BxU7-GW for pgsql-general@arkaria.postgresql.org; Sat, 18 May 2024 15:03:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s8LbA-007DvI-EI for pgsql-general@arkaria.postgresql.org; Sat, 18 May 2024 15:03:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s8LbA-007Dv8-3M for pgsql-general@lists.postgresql.org; Sat, 18 May 2024 15:03:48 +0000 Received: from fout6-smtp.messagingengine.com ([103.168.172.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s8Lb6-000tNS-7p for pgsql-general@lists.postgresql.org; Sat, 18 May 2024 15:03:46 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id C7E581380DEF; Sat, 18 May 2024 11:03:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sat, 18 May 2024 11:03:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1716044623; x=1716131023; bh=P7kVhvVy8Jpp8ghbTVIaYfBt6t/+PHCfK4Nhi8dZG9E=; b= GLYIuSKXhx7p7lQLSVEQCKSaYgerJqZoaGfaJhIGNF/k9u4WbLO6OG0TxTaU4Y8w 8d4zNJMr4qxF9ByLZ8eIgnUQClhyAAb8bPYXn41TC9aSOG6KORWQpDzq6APtfXgZ 6w4xs9AVzcw1I95fzD2ieZZeJBYsWYUFqjG0ByxklM2YbxG7t0rsonzIBHdC0CkR RqIrN2VPA3HtxNYJTtlHxvhMyShHFhniFKrECI4lboNLSzJ/ZXmbbHwj9DYiK5UD mTqNCgzTnY1q/ozqRm9tKhMfFUw7MNStw2qGb7TkdjZWWUf0vyyT4lebvl1tq8/u BreV/kPWE1YUJ0BEh4oCRw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1716044623; x= 1716131023; bh=P7kVhvVy8Jpp8ghbTVIaYfBt6t/+PHCfK4Nhi8dZG9E=; b=S 3uNv8G1jE2h76cvXEWvgIiOi0HFVKE8d+fV0HIH/l3lBnajBDLqSeovvaduBbJIc UMptWaWc1HLgcZVfMeKiLN6+gf89pNVVIczw1mRg60mQv5WnR/8NCCOsMRvGeIU8 XgBZi05GEYgCVrjqTdzhHH3RhiBG3FGtYCN+FHX5NX4Vzpvnbj693WuZEDAQpNWs 47owTEYSfTULQw1utvJdy/sc99whgFau91RDque9VikAx6tOCVQg+2GXWHBUOh0C m1I6ceR9Xi6KwRQu2yXgMKX8RZ4ZlWMGGZHSudaJkShMHCmhH6AJ4yDywv8ljdZy vH63GdOSoptkmWUIGQPJw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdehiedgieejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeffleegieefgfevudehtdfhkeeutdffjeevgeffgeej vedthefgudeiteefheejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 May 2024 11:03:43 -0400 (EDT) Message-ID: <2e4c19a5-9547-40cc-93e3-75776547b26f@aklaver.com> Date: Sat, 18 May 2024 08:03:42 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Left join syntax error To: Rich Shepard , pgsql-general@lists.postgresql.org References: <2c877258-61cc-dd2d-fac7-4f2a5c6293e7@appl-ecosys.com> <9d899286-3a73-4894-a6e0-eab529c92e65@gmx.net> <3216489-758a-faef-b21b-84c9679f53c@appl-ecosys.com> <23486d5-be1e-f152-2b97-e027ef89a810@appl-ecosys.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: <23486d5-be1e-f152-2b97-e027ef89a810@appl-ecosys.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 5/18/24 08:01, Rich Shepard wrote: > On Sat, 18 May 2024, Ray O'Donnell wrote: > >> You need to include the alias for the table also - see "...from >> companies as c..." in Shammat's example. > > Ray, > > That didn't work: > bustrac-# FROM people as p, companies as c > bustrac-# LEFT JOIN companies as c ON c.company_nbr = p.company_nbr; > ERROR:  table name "c" specified more than once > > so I tried only the alias on the join line: > bustrac-# LEFT JOIN c ON c.company_nbr = p.company_nbr; > ERROR:  relation "c" does not exist > LINE 3: LEFT JOIN c ON c.company_nbr = p.company_nbr; >                   ^ > and that didn't work either. The query needs to be: SELECT p.lname, p.fname, p.job_title, p.company_nbr, p.email, c.company_name FROM people as p LEFT JOIN companies as c ON c.company_nbr = p.company_nbr; Only reference companies as c once. > > Thanks, > > Rich > > -- Adrian Klaver adrian.klaver@aklaver.com