Re: Left join syntax error

Erik Wienhold <ewie@ewie.name>

From: Erik Wienhold <ewie@ewie.name>
To: Shammat <shammat@gmx.net>
Cc: pgsql-general@lists.postgresql.org
Date: 2024-05-18T15:14:32Z
Lists: pgsql-general
I wrote:
> But I wonder if the implicit cross join syntax ("FROM peoples, companies")
> should actually produce this error because the explicit cross join
> works:
> 
>     SELECT p.lname, p.fname, p.job_title, p.company_nbr, p.email, c.company_name
>     FROM people as p
>         CROSS JOIN companies as c
>         LEFT JOIN companies ON c.company_nbr = p.company_nbr;

On second thought it looks like that (companies as c LEFT JOIN companies)
actually is the second FROM item.  Adding parenthesis to the explicit
cross join version gives the same error:

    SELECT p.lname, p.fname, p.job_title, p.company_nbr, p.email, c.company_name
    FROM people as p
        CROSS JOIN (
            companies as c
            LEFT JOIN companies ON c.company_nbr = p.company_nbr
        );

So the comma in the FROM item list has lower precedence than the join
operators.

-- 
Erik