public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: Adrian Klaver <[email protected]>
Cc: Rich Shepard <[email protected]>
Cc: [email protected]
Subject: Re: Left join syntax error
Date: Sat, 18 May 2024 08:27:19 -0700
Message-ID: <CAKFQuwYoRuZkkzA9AM14+qLGGzbtUmnbQr_y5=WqXmwrYPJ7UA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>

On Sat, May 18, 2024 at 7:49 AM Adrian Klaver <[email protected]>
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 = 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 = p.company_nbr;
>
> ... LEFT JOIN companies as c ON c.company_nbr = 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.


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: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Left join syntax error
  In-Reply-To: <CAKFQuwYoRuZkkzA9AM14+qLGGzbtUmnbQr_y5=WqXmwrYPJ7UA@mail.gmail.com>

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

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