Re: Left join syntax error

From: Ray O'Donnell <ray(at)rodonnell(dot)ie>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Left join syntax error
Date: 2024-05-18 14:49:02
Message-ID: defe498f-d82c-4c51-ac83-77cb3d3a1152@rodonnell.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 18/05/2024 15: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;
>

You need to include the alias for the table also - see "...from
companies as c..." in Shammat's example.

Ray.

--
Raymond O'Donnell // Galway // Ireland
ray(at)rodonnell(dot)ie

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2024-05-18 14:49:12 Re: Left join syntax error
Previous Message Troels Arvin 2024-05-18 14:48:36 Re: utf8 vs UTF-8