Re: Left join syntax error
Erik Wienhold <ewie@ewie.name>
From: Erik Wienhold <ewie@ewie.name>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: Shammat <shammat@gmx.net>, "pgsql-general@lists.postgresql.org" <pgsql-general@lists.postgresql.org>
Date: 2024-05-18T15:30:36Z
Lists: 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