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

From Erik Wienhold
Subject Re: Left join syntax error
Date
Msg-id 5150aba7-b6e4-4c40-a357-9dd7528ec870@ewie.name
Whole thread Raw
In response to Re: Left join syntax error  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
On 2024-05-18 17:12 +0200, David G. Johnston wrote:
> Too lazy to find the docs right now but what you are observing is basically
> an operator precedence effect.  The comma join hasn’t happened at the time
> the left join is evaluated and so other tables in the comma join cannot
> appear in the on clause of the left join.  Placing everything inside a
> single from slot and moving the conditions to the where clause removes
> changes the precedence aspect so that the cross join does indeed evaluate
> prior to the left join.

Thanks David.  The docs on table expressions clarify the precedence:

https://www.postgresql.org/docs/16/queries-table-expressions.html#QUERIES-FROM

I'm using SQL for 17 years now and yet I still forget that joins are
table expressions m(

-- 
Erik



pgsql-general by date:

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