BUG ? or SQL miss understanding ?

Started by Bogdan Vatkovalmost 22 years ago3 messagesgeneral
Jump to latest
#1Bogdan Vatkov
bvatkov@globaltech-bg.com

Any idea for this ?! thanx in advance.

SQL error:
ERROR: JOIN/ON clause refers to "vras_audio_records", which is not part of JOIN

In statement:
set search_path = excel,audio_records;
SELECT vras_audio_records.vras_id AS VRASID,vras_audio_records.audio_record_id AS ANNID, (announcements.description || ' - ' || languages.name) AS ANNNAME

FROM

vras_audio_records, (SELECT announcements.description,languages.name from
announcements,
languages,
announcement_records,
audio_records
WHERE
audio_records.id = announcement_records.audio_record_id
AND announcements.id = announcement_records.announcement_id
AND languages.id = announcement_records.language_id
AND vras_audio_records.audio_record_id = audio_records.id
) AS AA

LEFT JOIN (
audio_records_groups_vras
CROSS JOIN audio_records_groups_audio_records
CROSS JOIN audio_records_groups )
ON vras_audio_records.vras_id = audio_records_groups_vras.vras_id
AND vras_audio_records.audio_record_id = audio_records_groups_audio_records.audio_record_id
AND audio_records_groups_vras.audio_records_group_id = audio_records_groups_audio_records.audio_records_group_id
AND audio_records_groups_vras.audio_records_group_id = audio_records_groups.id

WHERE audio_records_groups.id IS NULL

#2Manfred Koizar
mkoi-pg@aon.at
In reply to: Bogdan Vatkov (#1)
Re: BUG ? or SQL miss understanding ?

On Wed, 28 Apr 2004 12:33:15 +0300, "Bogdan Vatkov"
<bvatkov@globaltech-bg.com> wrote:

SQL error:
ERROR: JOIN/ON clause refers to "vras_audio_records", which is not part of JOIN

In
SELECT ... FROM a, b LEFT JOIN c ON (a.id = ...)

the LEFT JOIN operator has higher precedence than the comma, so "a" is
not part of the JOIN. Better use ANSI syntax consistently:

SELECT ... FROM a INNER JOIN b ON (....)
LEFT JOIN c ON (....)

Servus
Manfred

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Manfred Koizar (#2)
Re: BUG ? or SQL miss understanding ?

Manfred Koizar <mkoi-pg@aon.at> writes:

In
SELECT ... FROM a, b LEFT JOIN c ON (a.id = ...)
the LEFT JOIN operator has higher precedence than the comma, so "a" is
not part of the JOIN. Better use ANSI syntax consistently:

BTW, a lot of people coming from MySQL get this wrong. According to
what I've heard, MySQL considers JOIN to have the same precedence as
comma, so that the above would in fact work as the OP seems to expect.
However, MySQL is flatly in violation of the SQL standard on this
point :-(

regards, tom lane