Icon View Incident Report

Serious Serious
Reported By: Michael Binette
Reported On: 6/7/2004
For: Version 3.29 Build 1
# 1815 Specify SQL INNER JOINs in a SELECT Statement that Refer to One Another Can Cause Incorrect Results

When I run this sql, I end up with no rows. If I change the last INNER JOIN statement to read

INNER JOIN transaction_amount ON trans_internal_id = ta_linkto_trans

I get the expected results including what looks like a bunch of rows that would have satisfied the second part of the INNER JOIN definition, after the AND.

SELECT
 bp_internal_id,
 ta_linkto_bp,
 trans_internal_id,
 ta_linkto_trans,
 trans_linkto_pa,
 trans_linkto_bp,
 ta_amount,
 trans_amount
FROM
 billing_parties
 INNER JOIN transactions ON bp_linkto_pa = trans_linkto_pa
 INNER JOIN transaction_amount ON trans_internal_id = ta_linkto_trans AND 
ta_linkto_bp = bp_internal_id



Comments Comments and Workarounds
The problem was with the join optimization, which was throwing off the second condition in the second join that caused a join back to the first table in the SELECT statement. Once the tables were rearranged due to the join optimization, this condition was not evaluated in the correct order, resulting in the improper results. The workaround was to add a NOJOINOPTIMIZE clause to the end of the query.


Resolution Resolution
Fixed Problem on 6/7/2004 in version 3.30 build 1
Image