<?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: How to write SQL JOIN clauses more compactly</title>
	<atom:link href="http://www.xaprb.com/blog/2006/11/28/how-to-write-sql-join-clauses-more-compactly/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xaprb.com/blog/2006/11/28/how-to-write-sql-join-clauses-more-compactly/</link>
	<description>Stay curious!</description>
	<lastBuildDate>Thu, 09 Feb 2012 09:56:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Alexandru Toth</title>
		<link>http://www.xaprb.com/blog/2006/11/28/how-to-write-sql-join-clauses-more-compactly/#comment-16574</link>
		<dc:creator>Alexandru Toth</dc:creator>
		<pubDate>Sat, 20 Jun 2009 19:38:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=267#comment-16574</guid>
		<description>Hi,

You said: The statement is valid and will execute, but it wonâ€™t give the results you probably wanted (tbl4â€™s join clause doesnâ€™t refer to any columns from tbl4). 

select tbl1.col1, tbl2.col2, tbl3.col2, tbl4.col1
from apples as tbl1
   inner join oranges as tbl2 on tbl1.col3 = tbl2.col3
   inner join grapes as tbl3 on tbl3.col3 = tbl2.col3
   inner join peaches as tbl4 on tbl3.col3 = tbl2.col3

Fully agree, and would like to show the diagram generated by the open source project revj : http://snowflakejoins.com/static/xaprb.png

In the diagram it is quite evident that there is a cartezian join

You can try the tool online at:http://snowflakejoins.com/revj/index
 

Cheers, Alex
http://sourceforge.net/projects/revj/</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>You said: The statement is valid and will execute, but it wonâ€™t give the results you probably wanted (tbl4â€™s join clause doesnâ€™t refer to any columns from tbl4). </p>
<p>select tbl1.col1, tbl2.col2, tbl3.col2, tbl4.col1<br />
from apples as tbl1<br />
   inner join oranges as tbl2 on tbl1.col3 = tbl2.col3<br />
   inner join grapes as tbl3 on tbl3.col3 = tbl2.col3<br />
   inner join peaches as tbl4 on tbl3.col3 = tbl2.col3</p>
<p>Fully agree, and would like to show the diagram generated by the open source project revj : <a href="http://snowflakejoins.com/static/xaprb.png" rel="nofollow">http://snowflakejoins.com/static/xaprb.png</a></p>
<p>In the diagram it is quite evident that there is a cartezian join</p>
<p>You can try the tool online at:<a href="http://snowflakejoins.com/revj/index" rel="nofollow">http://snowflakejoins.com/revj/index</a></p>
<p>Cheers, Alex<br />
<a href="http://sourceforge.net/projects/revj/" rel="nofollow">http://sourceforge.net/projects/revj/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rye</title>
		<link>http://www.xaprb.com/blog/2006/11/28/how-to-write-sql-join-clauses-more-compactly/#comment-5752</link>
		<dc:creator>rye</dc:creator>
		<pubDate>Sun, 15 Apr 2007 07:24:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=267#comment-5752</guid>
		<description>&lt;p&gt;Well another difference between join with &#039;on&#039; and join with &#039;using&#039; is that when &quot;select *&quot; is used, with &quot;on&quot; the joined column will be presented twice, while with &quot;using&#039; only once and placed as the first column.

Another point I think noteworthy is that with &quot;using&quot; the joined column must be enclosed in parenthesis/&quot;()&quot;, without them it&#039;s an error.

ok the DBMS I play with is mysql 5.0.27 on NT.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Well another difference between join with &#8216;on&#8217; and join with &#8216;using&#8217; is that when &#8220;select *&#8221; is used, with &#8220;on&#8221; the joined column will be presented twice, while with &#8220;using&#8217; only once and placed as the first column.</p>
<p>Another point I think noteworthy is that with &#8220;using&#8221; the joined column must be enclosed in parenthesis/&#8221;()&#8221;, without them it&#8217;s an error.</p>
<p>ok the DBMS I play with is mysql 5.0.27 on NT.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Binary Look &#187; links for 2006-12-09</title>
		<link>http://www.xaprb.com/blog/2006/11/28/how-to-write-sql-join-clauses-more-compactly/#comment-2757</link>
		<dc:creator>Binary Look &#187; links for 2006-12-09</dc:creator>
		<pubDate>Sat, 09 Dec 2006 22:22:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=267#comment-2757</guid>
		<description>&lt;p&gt;[...] How to write SQL JOIN clauses more compactly - Xaprb ÐÐ°Ð¿Ð¸ÑÐ°Ð½Ð¸Ðµ ÐºÐ¾Ð¼Ð¿Ð°ÐºÑ‚Ð½Ð¾Ð³Ð¾ ÐºÐ¾Ð´Ð° SQL Ð¿Ñ€Ð¸Ð¼ÐµÐ½Ð¸Ñ‚ÐµÐ»ÑŒÐ½Ð¾ Ðº JOIN. (tags: sql mysql join select ÐºÐ¾Ð´ Ð¿Ñ€Ð¾Ð³Ñ€Ð°Ð¼Ð¼Ð¸Ñ€Ð¾Ð²Ð°Ð½Ð¸Ðµ Ð±Ð°Ð·Ñ‹_Ð´Ð°Ð½Ð½Ñ‹Ñ…) [...]&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>[...] How to write SQL JOIN clauses more compactly &#8211; Xaprb ÐÐ°Ð¿Ð¸ÑÐ°Ð½Ð¸Ðµ ÐºÐ¾Ð¼Ð¿Ð°ÐºÑ‚Ð½Ð¾Ð³Ð¾ ÐºÐ¾Ð´Ð° SQL Ð¿Ñ€Ð¸Ð¼ÐµÐ½Ð¸Ñ‚ÐµÐ»ÑŒÐ½Ð¾ Ðº JOIN. (tags: sql mysql join select ÐºÐ¾Ð´ Ð¿Ñ€Ð¾Ð³Ñ€Ð°Ð¼Ð¼Ð¸Ñ€Ð¾Ð²Ð°Ð½Ð¸Ðµ Ð±Ð°Ð·Ñ‹_Ð´Ð°Ð½Ð½Ñ‹Ñ…) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2006/11/28/how-to-write-sql-join-clauses-more-compactly/#comment-2667</link>
		<dc:creator>Xaprb</dc:creator>
		<pubDate>Wed, 29 Nov 2006 19:30:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=267#comment-2667</guid>
		<description>&lt;p&gt;Rudy, very good points.&lt;/p&gt;

&lt;p&gt;Disclosure: there is not a single USING in any codebase I&#039;m involved with.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Rudy, very good points.</p>
<p>Disclosure: there is not a single USING in any codebase I&#8217;m involved with.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rudy</title>
		<link>http://www.xaprb.com/blog/2006/11/28/how-to-write-sql-join-clauses-more-compactly/#comment-2659</link>
		<dc:creator>rudy</dc:creator>
		<pubDate>Wed, 29 Nov 2006 13:30:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=267#comment-2659</guid>
		<description>&lt;p&gt;i don&#039;t like USING either, because it&#039;s vague and can, in certain circumstances, produce ridiculous results&lt;/p&gt;
&lt;p&gt;in the example you gave:&lt;/p&gt;
&lt;pre&gt;select tbl1.col1, tbl2.col2, tbl3.col2, tbl4.col1
from apples as tbl1
   inner join oranges as tbl2 using(col3)
   inner join grapes as tbl3 using(col3)
   inner join peaches as tbl4 using(col3)&lt;/pre&gt;
&lt;p&gt;you say that &quot;USING matches the specified columns from each table&quot; but this is problematic -- is it really &lt;b&gt;each&lt;/b&gt; table?&lt;/p&gt;
&lt;p&gt;in this case, col3 exists in all 4 tables, so does this mean that the last USING is equivalent to:&lt;/p&gt;
&lt;pre&gt; on tbl4.col3 = tbl3.col3
and tbl4.col3 = tbl2.col3
and tbl4.col3 = tbl1.col3&lt;/pre&gt;
&lt;p&gt;and don&#039;t get me started on NATURAL joins -- &lt;em&gt;what were they thinking?!!!&lt;/em&gt;&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>i don&#8217;t like USING either, because it&#8217;s vague and can, in certain circumstances, produce ridiculous results</p>
<p>in the example you gave:</p>
<pre>select tbl1.col1, tbl2.col2, tbl3.col2, tbl4.col1
from apples as tbl1
   inner join oranges as tbl2 using(col3)
   inner join grapes as tbl3 using(col3)
   inner join peaches as tbl4 using(col3)</pre>
<p>you say that &#8220;USING matches the specified columns from each table&#8221; but this is problematic &#8212; is it really <b>each</b> table?</p>
<p>in this case, col3 exists in all 4 tables, so does this mean that the last USING is equivalent to:</p>
<pre> on tbl4.col3 = tbl3.col3
and tbl4.col3 = tbl2.col3
and tbl4.col3 = tbl1.col3</pre>
<p>and don&#8217;t get me started on NATURAL joins &#8212; <em>what were they thinking?!!!</em></p>
]]></content:encoded>
	</item>
</channel>
</rss>

