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 1s8Lyb-00BzmF-H1 for pgsql-general@arkaria.postgresql.org; Sat, 18 May 2024 15:28:02 +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 1s8Lyb-007sxh-5H for pgsql-general@arkaria.postgresql.org; Sat, 18 May 2024 15:28:01 +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 1s8Lya-007sxZ-R1 for pgsql-general@lists.postgresql.org; Sat, 18 May 2024 15:28:00 +0000 Received: from mail-oo1-xc34.google.com ([2607:f8b0:4864:20::c34]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s8LyX-000taW-If for pgsql-general@lists.postgresql.org; Sat, 18 May 2024 15:28:00 +0000 Received: by mail-oo1-xc34.google.com with SMTP id 006d021491bc7-5b27ce83663so580966eaf.0 for ; Sat, 18 May 2024 08:27:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716046076; x=1716650876; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=OatmH3xQ89Cx79h7muYxOioXR/89UOJO6gIPcA+nFdE=; b=CuxKuuPTd6PyKveO9IoUul0jpniPeBNYH770fHXEN/UlSEziSsTQWHkTwvBBN7Mtgu 3UEGC3Yw2uV0/pn40ZNtW3emRy2e2j7uejLQv0/pov0BKa5anYt9rKcR/DXXlnipYsfo F07fbI06+6cc51YvSp9L7CewjW2MWH291VkwD1Acn35J8er7dsAFLX8aYerZYAdkwCIg QefRSDPWYdSRBsw+YDeg8Q721TgOiGRbtyt2IKPA83a+YZB4PaFLFqSEURx8+7vQ4JZS luZge9Yn1ILVLObA/BMI/unr+QVRxNFzH46A3BP6ezcj2ZRLKkHhrVELPV++KMi+4f3d DUYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716046076; x=1716650876; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OatmH3xQ89Cx79h7muYxOioXR/89UOJO6gIPcA+nFdE=; b=MzoXLUIkSuoN105SklHazYkQyt+liU3smqMoApN1FjdziW2LRuMSdkJobCa30loboh Fa01iawzSIWnm8GzX7+M1SUBsBYjxq93Q0IkuPHuc52Qi+69c/4QXvmrJ/oqpV1anlzA zGjw0JmBJZIA3W/JaVHdBhpUJdgAaYs4jEXWF9KkejRt2exxKbOBlIxb/uQMkXK3QlBP I9rwiBIDye0xl9vb4RzvTn8j0suOtawC85OPTl3lrs94aepAR/oaYm7bpZnYKZCsTCdo QydEdmutzw/vhJWxRwTVAyF5SK9reN+c+PGe2WiLQp0iHccfO2ORXBEhrK9DQL8ELRjx itRQ== X-Forwarded-Encrypted: i=1; AJvYcCUN28QOBBX8VFhrcIqJJUODj/i3x9bwiXJ+iE7MHAg4h1cNHJq6ZykjpbF1JYO+eRupq3AdEu1//r2GBVU2sLYh5S/9G0IyzluMDMAam4Ns0h6T X-Gm-Message-State: AOJu0Yy95m0c6cy5OjdbhbuXVX3WS8mwsTAmC6pOmGSceekJwOaa6kl+ VsFd85NG6I06iCRLQug/3o04+25Mv2EFjOMlp9KRA+ZyeS5t4MZdJ3vuKTD+iHZ5F4s8Mbn9X2A iQJLQbLRgnGGaratlc4pHC6ydhkc= X-Google-Smtp-Source: AGHT+IHFtzvrHH357NCI3Mkgy0rNodea24X8BbpxyYd4XBd2LvBeiZCzkAUfyKh9kgede8UGMH0cR3GeuDKHpHlBOlo= X-Received: by 2002:a4a:98e9:0:b0:5aa:4b31:50c5 with SMTP id 006d021491bc7-5b281856d44mr21706915eaf.2.1716046076540; Sat, 18 May 2024 08:27:56 -0700 (PDT) MIME-Version: 1.0 References: <2c877258-61cc-dd2d-fac7-4f2a5c6293e7@appl-ecosys.com> <9d899286-3a73-4894-a6e0-eab529c92e65@gmx.net> <3216489-758a-faef-b21b-84c9679f53c@appl-ecosys.com> In-Reply-To: From: "David G. Johnston" Date: Sat, 18 May 2024 08:27:19 -0700 Message-ID: Subject: Re: Left join syntax error To: Adrian Klaver Cc: Rich Shepard , pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000cf7f410618bc1cdc" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000cf7f410618bc1cdc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, May 18, 2024 at 7:49=E2=80=AFAM Adrian Klaver wrote: > On 5/18/24 07:46, Rich Shepard wrote: > > On Sat, 18 May 2024, Shammat wrote: > > > >> Don't put the second table in the FROM part > >> > >> 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 =3D p.company_nbr > > > > Shammat, > > > > I tried this with this result: > > > > ERROR: missing FROM-clause entry for table "c" > > LINE 3: LEFT JOIN companies ON c.company_nbr =3D p.company_nbr; > > ... LEFT JOIN companies as c ON c.company_nbr =3D p.company_nbr; > > You failed at copy-and-paste. If you use the exact query provided it will indeed work. If you want to explain why you thought writing in the company table twice into the FROM clause of the query was a good idea maybe we can help you unlearn that bad belief. Otherwise feel free to just take the answer you've been given. David J. --000000000000cf7f410618bc1cdc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sat, May 18, 2024 at 7:49=E2=80=AFAM Adrian Klaver <= adrian.klaver@aklaver.com&= gt; wrote:
On 5/18/24 07:46, Rich Shepard wrote: > On Sat, 18 May 2024, Shammat wrote:
>
>> Don't put the second table in the FROM part
>>
>> SELECT p.lname, p.fname, p.job_title, p.company_nbr, p.email,
>> c.company_name
>> FROM people as p
>> =C2=A0LEFT JOIN companies as c ON c.company_nbr =3D p.company_nbr<= br> >
> Shammat,
>
> I tried this with this result:
>
> ERROR:=C2=A0 missing FROM-clause entry for table "c"
> LINE 3: LEFT JOIN companies ON c.company_nbr =3D p.company_nbr;

... LEFT JOIN companies as c ON c.company_nbr =3D p.company_nbr;


You failed at copy-and-paste.=C2=A0 If you use = the exact query provided it will indeed work.

If you = want to explain why you thought writing=C2=A0in the company table twice int= o the FROM clause of the query was a good idea maybe we can help you unlear= n that bad belief.=C2=A0 Otherwise feel free to just take the answer you= 9;ve been given.

David J.

--000000000000cf7f410618bc1cdc--