Re: Left join syntax error

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Left join syntax error
Дата
Msg-id CAKFQuwYoRuZkkzA9AM14+qLGGzbtUmnbQr_y5=WqXmwrYPJ7UA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Left join syntax error  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
On Sat, May 18, 2024 at 7:49 AM Adrian Klaver <adrian.klaver@aklaver.com> 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.

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: utf8 vs UTF-8
Следующее
От: Erik Wienhold
Дата:
Сообщение: Re: Left join syntax error