Re: Left join syntax error - Mailing list pgsql-general

From Erik Wienhold
Subject Re: Left join syntax error
Date
Msg-id 4dde36a5-a22e-452a-b395-85ac7bd6bc05@ewie.name
Whole thread Raw
In response to Re: Left join syntax error  (Erik Wienhold <ewie@ewie.name>)
List 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



pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Left join syntax error
Next
From: Tom Lane
Date:
Subject: Re: Left join syntax error