public inbox for [email protected]  
help / color / mirror / Atom feed
From: Erik Wienhold <[email protected]>
To: David G. Johnston <[email protected]>
Cc: Shammat <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: Left join syntax error
Date: Sat, 18 May 2024 17:30:36 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAKFQuwZs4ma+K4XS7x6waVbHa6J4=FzpPhK+_TLXMnyFJzdkZQ@mail.gmail.com>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<CAKFQuwZs4ma+K4XS7x6waVbHa6J4=FzpPhK+_TLXMnyFJzdkZQ@mail.gmail.com>

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






view thread (6+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Left join syntax error
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox