Re: PostgreSQL select

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Jiří Němec <konference(at)menea(dot)cz>, pgsql-general(at)postgresql(dot)org
Subject: Re: PostgreSQL select
Date: 2005-07-16 14:46:59
Message-ID: 25515.1121525219@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> writes:
> On Sat, 16 Jul 2005, [ISO-8859-2] Ji Nmec wrote:
>> There's a problem with PostgreSQL 8.0.3 SELECT. All tables exist, all
>> columns exist, I have no idea where's the problem :/ PostgreSQL
>> reports this error: ERROR: relation "fieldx" does not exist...
>>
>> SELECT fieldx.field_id, COUNT(optionx.option_id) AS field_options
>> FROM c_custom_fields AS fieldx, j_product_groups_fields AS join_table
>> LEFT JOIN c_custom_fields_options AS optionx ON optionx.field_id = fieldx.field_id

> Our reading of the spec is that fieldx is not in scope for that left
> join's on condition since effectively join has higher precedence than
> comma separating items in the from list.

In other words: what you probably meant here is

FROM (c_custom_fields AS fieldx CROSS JOIN j_product_groups_fields AS join_table)
LEFT JOIN c_custom_fields_options AS optionx ON optionx.field_id = fieldx.field_id

(The parentheses aren't required in this particular case but they help
clarify your intent.)

We are aware that there are certain standards-challenged products
that get this wrong.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-07-16 15:01:34 Re: encoding and locale
Previous Message Thomas Chille 2005-07-16 14:05:42 Re: 7.3.4 dump/restore error