Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s8M1L-00C05v-8b for pgsql-general@arkaria.postgresql.org; Sat, 18 May 2024 15:30:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s8M1K-007wl3-P3 for pgsql-general@arkaria.postgresql.org; Sat, 18 May 2024 15:30:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s8M1K-007wkv-Ce for pgsql-general@lists.postgresql.org; Sat, 18 May 2024 15:30:50 +0000 Received: from mout-u-107.mailbox.org ([80.241.59.207]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s8M1D-000ptN-3H for pgsql-general@lists.postgresql.org; Sat, 18 May 2024 15:30:49 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4VhSTB6XPyz9sTP; Sat, 18 May 2024 17:30:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1716046239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P4wHYYWgWD43YF9r9H+cAFLA32brrvd73AC/Q/JUXg0=; b=KLGMh08ZC9UQCC7hKQoVNNqsGksFvz7I8eRtTgFPi3PA9O8Uev3ssREkQpelihV2iqXrkC QY1US22mOjHMwDq86fRM1YfmYbPoJ0JSpmNW61br/H3XUUrSo8gQee5LwDbyTiUD4WzHPF O4Y0MNGXKBLgzU8SShf0g3pf9ChBTpX0b/4xBWnW0Z65QxWYFzn6xY+Pf6e8OGD7DNdMbD v8HyD0gw+nEWEcnZBsBYEFbaz8u1UT6rla5aDDY0SCHc7tv+giGNMoZ8BxTw4aTIHoyJSO 10RAUGGk4NdGdLWn8vOi5q4jPZSHz48N6DDjtjJzsUsy2HFuimKGNcct+h3zMg== Date: Sat, 18 May 2024 17:30:36 +0200 From: Erik Wienhold To: "David G. Johnston" Cc: Shammat , "pgsql-general@lists.postgresql.org" Subject: Re: Left join syntax error Message-ID: <5150aba7-b6e4-4c40-a357-9dd7528ec870@ewie.name> References: <2c877258-61cc-dd2d-fac7-4f2a5c6293e7@appl-ecosys.com> <9d899286-3a73-4894-a6e0-eab529c92e65@gmx.net> <7d422a60-c581-485d-b5fd-4b2bb284b919@ewie.name> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: 4VhSTB6XPyz9sTP List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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