|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Sunday, March 17, 2013 5:34 PM
Points: 521,
Visits: 543
|
|
True and correct. I just put in the example code for the old style. I had actually noticed the execution plans were pretty much identical. How people can still write in that scares me 
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 3:04 PM
Points: 13,375,
Visits: 25,159
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, August 18, 2006 8:35 AM
Points: 15,
Visits: 1
|
|
Hi, This article & discussion is very interesting and it helped me a lot in understanding the Outer Join Query plus the old vs. new syntax. Thanks once again Regards Amit Gurjar
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, October 23, 2012 8:49 AM
Points: 24,
Visits: 17
|
|
To get the Execution plans to match between the old and new syntax, the "old style" join query needs to look something like this: SELECT S.IIATransactionId ,substring(rats_filename,1+patindex('%{________-____-____-____-____________}%',rats_filename),36) AS OracleTransactionId FROM iiafeedtransaction S, ratsiiafeedtransaction o WHERE S.IIATransactionId *= substring(rats_filename,1+patindex('%{________-____-____-____-____________}%',rats_filename),36) GROUP BY S.IIATransactionId,substring(rats_filename,1+patindex('%{________-____-____-____-____________}%',rats_filename),36) HAVING substring(rats_filename,1+patindex('%{________-____-____-____-____________}%',rats_filename),36) IS NULL ORDER BY S.IIATransactionId
Using the GROUP BY and the HAVING clauses puts the filter back into the execution plan and the correct results are seen. Far easier to just use the new style of joins  Regards, Mark Horton.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, January 30, 2008 2:38 PM
Points: 36,
Visits: 2
|
|
Because you dont have control over the order of WHERE clause execution, the WHERE condition can occur before the JOIN condition, meaning that the WHERE occurs on the *Cartesian Product* of the two tables, and therefore doesnt filter rows properly. If you think about this closely enough, it makes sense.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, June 06, 2006 1:55 PM
Points: 1,
Visits: 1
|
|
| So, how does Oracle return the "right" results?
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 1:39 PM
Points: 2,818,
Visits: 1,038
|
|
The use of the old-style syntax promoted the entire WHERE clause to the ON clause. You get the same results as the "wrong" query if you used "LEFT JOIN ... ON S. = O. AND o.rats_filename IS NOT NULL". The IS NOT NULL condition is being used as a a join condition instead of a filter condition and, since none of the fields are null, has no effect. The only mystery to me is how Oracle differentiates join conditions and filter conditions. Maybe only logical comparisons involving both tables are considered join conditions?
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 3:04 PM
Points: 13,375,
Visits: 25,159
|
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 3:04 PM
Points: 13,375,
Visits: 25,159
|
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, November 14, 2012 10:10 AM
Points: 39,
Visits: 55
|
|
Itzik Ben-Gan wrote an article that explains this very clearly in SQL Magazine in the October 2004 issue. The InstantDoc ID is #43681. The problem is that in Old Style Joins, you can't separate the join clause and the Where Clause so the result may include extraneous NULL values in your result set. Here are two simple queries you can run in PUBS to see this: -- Old Style Join -- 13 Valid Entries, 6 Invalid Entries select o.name, i.name,i.indid from sysobjects o, sysindexes i where o.id *= i.id and o.type = 'S' and i.indid = 1 -- New Style Join -- 13 Valid Entries, 0 Invalid Entries select o.name, i.name,i.indid from sysobjects o left outer join sysindexes i on o.id = i.id where o.type = 'S' and i.indid = 1
|
|
|
|