<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: ANSI Outer Joins And Lateral Views</title>
	<atom:link href="http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/feed/" rel="self" type="application/rss+xml" />
	<link>http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/</link>
	<description>Oracle Database Performance And Scalability Blog</description>
	<lastBuildDate>Mon, 01 Mar 2010 22:11:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: simon</title>
		<link>http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/comment-page-1/#comment-169</link>
		<dc:creator>simon</dc:creator>
		<pubDate>Fri, 22 May 2009 11:39:13 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/#comment-169</guid>
		<description>Hi Jock
I think the fact that you use the ANSI style for tricky stuff shows that this is the best style! ;)  And surely its much nicer for someone maintaining someone elses code if they&#039;ve stuck to one style rather than kept switching styles.</description>
		<content:encoded><![CDATA[<p>Hi Jock<br />
I think the fact that you use the ANSI style for tricky stuff shows that this is the best style! ;)  And surely its much nicer for someone maintaining someone elses code if they&#8217;ve stuck to one style rather than kept switching styles.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jock</title>
		<link>http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/comment-page-1/#comment-161</link>
		<dc:creator>jock</dc:creator>
		<pubDate>Thu, 16 Apr 2009 04:31:23 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/#comment-161</guid>
		<description>I find that I only ever use ANSI style join when I encounter tricky outer join conditions which couldn&#039;t easily be tackled with (+), e.g. OR/IN, FULL OUTER,etc.

Other than that, ANSI style doesn&#039;t add any benefit at all. Some people say it&#039;s easier to read, but I just disagree. There&#039;s also the old argument of Standards, but again, not a single databases vendor can claim to be 100% fully ANSI compliant and thus no 2 databases are ever going to be the same (unless Oracle takes them over!), so unless you think you can move from DB1 to DB2 without having to learn DB vendor specific features, it&#039;s just pointless.</description>
		<content:encoded><![CDATA[<p>I find that I only ever use ANSI style join when I encounter tricky outer join conditions which couldn&#8217;t easily be tackled with (+), e.g. OR/IN, FULL OUTER,etc.</p>
<p>Other than that, ANSI style doesn&#8217;t add any benefit at all. Some people say it&#8217;s easier to read, but I just disagree. There&#8217;s also the old argument of Standards, but again, not a single databases vendor can claim to be 100% fully ANSI compliant and thus no 2 databases are ever going to be the same (unless Oracle takes them over!), so unless you think you can move from DB1 to DB2 without having to learn DB vendor specific features, it&#8217;s just pointless.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: simon</title>
		<link>http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/comment-page-1/#comment-157</link>
		<dc:creator>simon</dc:creator>
		<pubDate>Thu, 28 Aug 2008 12:34:46 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/#comment-157</guid>
		<description>Hi Dale
Yes of course I agree it is sometimes necessary to put the filtering in the ON clause of a LEFT OUTER join. My point was that it is never necessary to put the filtering in the ON clause of a REGULAR join. Therefore, if you avoid doing so you avoid any confusion over the differing semantics of filtering in the ON clause of regular and left-outer joins</description>
		<content:encoded><![CDATA[<p>Hi Dale<br />
Yes of course I agree it is sometimes necessary to put the filtering in the ON clause of a LEFT OUTER join. My point was that it is never necessary to put the filtering in the ON clause of a REGULAR join. Therefore, if you avoid doing so you avoid any confusion over the differing semantics of filtering in the ON clause of regular and left-outer joins</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dale</title>
		<link>http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/comment-page-1/#comment-162</link>
		<dc:creator>Dale</dc:creator>
		<pubDate>Thu, 21 Aug 2008 15:39:35 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/#comment-162</guid>
		<description>Hello Simon,

I concur with Doug&#039;s post of 6/12. It is sometimes necessary to include filtering in the join clause. Often for clarity&#039;s sake this is done in an inline view. Using Doug&#039;s example:

SELECT d.dname, d.deptno, e.ename
FROM   dept d LEFT OUTER JOIN emp e
ON     d.deptno = e.deptno and
       e.name like &#039;M%&#039;;

is the same as:

SELECT d.dname, d.deptno, e.ename
FROM   dept d LEFT OUTER JOIN
(select deptno, ename from emp
 where ename like &#039;M%&#039;) e
ON     d.deptno = e.deptno;</description>
		<content:encoded><![CDATA[<p>Hello Simon,</p>
<p>I concur with Doug&#8217;s post of 6/12. It is sometimes necessary to include filtering in the join clause. Often for clarity&#8217;s sake this is done in an inline view. Using Doug&#8217;s example:</p>
<p>SELECT d.dname, d.deptno, e.ename<br />
FROM   dept d LEFT OUTER JOIN emp e<br />
ON     d.deptno = e.deptno and<br />
       e.name like &#8216;M%&#8217;;</p>
<p>is the same as:</p>
<p>SELECT d.dname, d.deptno, e.ename<br />
FROM   dept d LEFT OUTER JOIN<br />
(select deptno, ename from emp<br />
 where ename like &#8216;M%&#8217;) e<br />
ON     d.deptno = e.deptno;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: simon</title>
		<link>http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/comment-page-1/#comment-153</link>
		<dc:creator>simon</dc:creator>
		<pubDate>Fri, 27 Jun 2008 10:58:22 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/#comment-153</guid>
		<description>Hi Doug
It is never necessary to put the filtering in the ON clause of a regular join, and this is what I was referring to - because the gist of this thread is that when a regular join with filtering conditions in the ON clause is converted to a left outer join the behaviour changes, and this was apparently confusing some people. So my suggestion is don&#039;t put filtering conditions in the ON clause of a regular join. In fact I think maybe it would be a good idea if this (non-joining conditions in the ON clause of a regular join) was made illegal SQL.

I know I&#039;m repeating myself here, but still not sure how an experienced sql coder can easily make the mistake of thinking that &quot;left&quot; table filtering conditions in the ON clause of a left outer join would have an effect though, as the fundamental contract of a left outer join is that rows from the &quot;left&quot; table that don’t meet the joining conditions WILL still appear in the result set.</description>
		<content:encoded><![CDATA[<p>Hi Doug<br />
It is never necessary to put the filtering in the ON clause of a regular join, and this is what I was referring to &#8211; because the gist of this thread is that when a regular join with filtering conditions in the ON clause is converted to a left outer join the behaviour changes, and this was apparently confusing some people. So my suggestion is don&#8217;t put filtering conditions in the ON clause of a regular join. In fact I think maybe it would be a good idea if this (non-joining conditions in the ON clause of a regular join) was made illegal SQL.</p>
<p>I know I&#8217;m repeating myself here, but still not sure how an experienced sql coder can easily make the mistake of thinking that &#8220;left&#8221; table filtering conditions in the ON clause of a left outer join would have an effect though, as the fundamental contract of a left outer join is that rows from the &#8220;left&#8221; table that don’t meet the joining conditions WILL still appear in the result set.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/comment-page-1/#comment-154</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Thu, 12 Jun 2008 21:13:05 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/#comment-154</guid>
		<description>To Simon:  But there are times when you *must* put the filtering in the ON clause.  For the LEFT OUTER JOIN, it&#039;s the right-hand side.  (So in the example above, if we wanted all departments, and also any employee whose name began with &quot;M&quot;.  The NAME LIKE &#039;M%&#039; would of course have to go in the ON clause.

So to even an experienced SQL coder, it&#039;s easy to make the mistake that a filter on the left-side table would also take effect, but it doesn&#039;t.</description>
		<content:encoded><![CDATA[<p>To Simon:  But there are times when you *must* put the filtering in the ON clause.  For the LEFT OUTER JOIN, it&#8217;s the right-hand side.  (So in the example above, if we wanted all departments, and also any employee whose name began with &#8220;M&#8221;.  The NAME LIKE &#8216;M%&#8217; would of course have to go in the ON clause.</p>
<p>So to even an experienced SQL coder, it&#8217;s easy to make the mistake that a filter on the left-side table would also take effect, but it doesn&#8217;t.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Rahn</title>
		<link>http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/comment-page-1/#comment-166</link>
		<dc:creator>Greg Rahn</dc:creator>
		<pubDate>Fri, 30 May 2008 16:02:14 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/#comment-166</guid>
		<description>Simon-

It&#039;s not at all about comparing apples and oranges.  It&#039;s about syntax that doesn&#039;t change the result set with a JOIN can very well change the result set with an OUTER JOIN because it changes the meaning of the query.  I agree 100% with your comments about good practice.  The facts are that many people do not realize this (as I&#039;ve seen this issue in a number of organizations) hence the whole reason I wrote this post: to educate and inform.

Cheers.</description>
		<content:encoded><![CDATA[<p>Simon-</p>
<p>It&#8217;s not at all about comparing apples and oranges.  It&#8217;s about syntax that doesn&#8217;t change the result set with a JOIN can very well change the result set with an OUTER JOIN because it changes the meaning of the query.  I agree 100% with your comments about good practice.  The facts are that many people do not realize this (as I&#8217;ve seen this issue in a number of organizations) hence the whole reason I wrote this post: to educate and inform.</p>
<p>Cheers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: simon</title>
		<link>http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/comment-page-1/#comment-168</link>
		<dc:creator>simon</dc:creator>
		<pubDate>Fri, 30 May 2008 15:44:54 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/#comment-168</guid>
		<description>Hi Greg

With respect, is that argument not akin to comparing &quot;apples and oranges&quot; ?  - an apple is green, but that doesn&#039;t mean that it is confusing that an orange isn&#039;t green, because an apple isn&#039;t an orange.

Likewise, a regular join isn&#039;t a left outer join, and it doesn&#039;t have the characteristics of one.

The fundamental contract of a regular join is that rows that don&#039;t meet the joining conditions WILL NOT appear in the result set. So when you add &quot;d.deptno in (10,40)&quot; to the joining conditions of your regular join it means that you DO NOT then see rows that don&#039;t meet that condition in your result set.

The fundamental contract of a left outer join is that rows from the &quot;left&quot; table that don&#039;t meet the joining conditions WILL still appear in your result set. So when you add &quot;d.deptno in (10,40)&quot; to the joining conditions of your left-outer join you DO still see rows that don&#039;t meet that condition in your result set.

I think this is a helpful thread and I agree that there is plenty of scope for someone to inadvertently produce results they didn&#039;t intend by incorrectly using these constructs, problems relating to which can be entirely avoided by what I would consider the good practice of putting only true joining conditions in the on clause and putting filtering conditions in the where clause.

Anyway, thanks for the interesting site Greg.</description>
		<content:encoded><![CDATA[<p>Hi Greg</p>
<p>With respect, is that argument not akin to comparing &#8220;apples and oranges&#8221; ?  &#8211; an apple is green, but that doesn&#8217;t mean that it is confusing that an orange isn&#8217;t green, because an apple isn&#8217;t an orange.</p>
<p>Likewise, a regular join isn&#8217;t a left outer join, and it doesn&#8217;t have the characteristics of one.</p>
<p>The fundamental contract of a regular join is that rows that don&#8217;t meet the joining conditions WILL NOT appear in the result set. So when you add &#8220;d.deptno in (10,40)&#8221; to the joining conditions of your regular join it means that you DO NOT then see rows that don&#8217;t meet that condition in your result set.</p>
<p>The fundamental contract of a left outer join is that rows from the &#8220;left&#8221; table that don&#8217;t meet the joining conditions WILL still appear in your result set. So when you add &#8220;d.deptno in (10,40)&#8221; to the joining conditions of your left-outer join you DO still see rows that don&#8217;t meet that condition in your result set.</p>
<p>I think this is a helpful thread and I agree that there is plenty of scope for someone to inadvertently produce results they didn&#8217;t intend by incorrectly using these constructs, problems relating to which can be entirely avoided by what I would consider the good practice of putting only true joining conditions in the on clause and putting filtering conditions in the where clause.</p>
<p>Anyway, thanks for the interesting site Greg.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Rahn</title>
		<link>http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/comment-page-1/#comment-165</link>
		<dc:creator>Greg Rahn</dc:creator>
		<pubDate>Fri, 30 May 2008 14:48:39 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/#comment-165</guid>
		<description>Simon-

I believe the reason there is confusion is that with regular joins this is not observed.

For example:

&lt;pre&gt;
SELECT d.dname, d.deptno, e.ename
FROM   dept d JOIN emp e
ON     d.deptno = e.deptno
WHERE  d.deptno in (10,40)
/

DNAME		   DEPTNO ENAME
-------------- ---------- ----------
ACCOUNTING	       10 CLARK
ACCOUNTING	       10 KING
ACCOUNTING	       10 MILLER

3 rows selected.

SELECT d.dname, d.deptno, e.ename
FROM   dept d JOIN emp e
ON     d.deptno = e.deptno
AND    d.deptno in (10,40)
/

DNAME		   DEPTNO ENAME
-------------- ---------- ----------
ACCOUNTING	       10 CLARK
ACCOUNTING	       10 KING
ACCOUNTING	       10 MILLER

3 rows selected.
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Simon-</p>
<p>I believe the reason there is confusion is that with regular joins this is not observed.</p>
<p>For example:</p>
<pre>
SELECT d.dname, d.deptno, e.ename
FROM   dept d JOIN emp e
ON     d.deptno = e.deptno
WHERE  d.deptno in (10,40)
/

DNAME		   DEPTNO ENAME
-------------- ---------- ----------
ACCOUNTING	       10 CLARK
ACCOUNTING	       10 KING
ACCOUNTING	       10 MILLER

3 rows selected.

SELECT d.dname, d.deptno, e.ename
FROM   dept d JOIN emp e
ON     d.deptno = e.deptno
AND    d.deptno in (10,40)
/

DNAME		   DEPTNO ENAME
-------------- ---------- ----------
ACCOUNTING	       10 CLARK
ACCOUNTING	       10 KING
ACCOUNTING	       10 MILLER

3 rows selected.
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: simon</title>
		<link>http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/comment-page-1/#comment-167</link>
		<dc:creator>simon</dc:creator>
		<pubDate>Fri, 30 May 2008 09:20:31 +0000</pubDate>
		<guid isPermaLink="false">http://structureddata.org/2008/02/18/ansi-outer-joins-and-lateral-views/#comment-167</guid>
		<description>Hi Greg

Yes of course moving the condition from the where clause to the on clause changes the semantics, but my point was why would one not expect that to be the case? If doing this didn&#039;t change the semantics then it would have broken what fundamentally a left outer join means - now that would be confusing!</description>
		<content:encoded><![CDATA[<p>Hi Greg</p>
<p>Yes of course moving the condition from the where clause to the on clause changes the semantics, but my point was why would one not expect that to be the case? If doing this didn&#8217;t change the semantics then it would have broken what fundamentally a left outer join means &#8211; now that would be confusing!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
