<?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: Proper SQL table alias use conventions</title>
	<atom:link href="http://code.openark.org/blog/mysql/proper-sql-table-alias-use-conventions/feed" rel="self" type="application/rss+xml" />
	<link>http://code.openark.org/blog/mysql/proper-sql-table-alias-use-conventions</link>
	<description>Blog by Shlomi Noach</description>
	<lastBuildDate>Wed, 01 Feb 2012 20:47:51 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: PHP-help &#187; Log Buffer #182, a Carnival of the Vanities for DBAs</title>
		<link>http://code.openark.org/blog/mysql/proper-sql-table-alias-use-conventions/comment-page-1#comment-11422</link>
		<dc:creator>PHP-help &#187; Log Buffer #182, a Carnival of the Vanities for DBAs</dc:creator>
		<pubDate>Fri, 12 Mar 2010 22:48:05 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=2156#comment-11422</guid>
		<description>[...] is no consistent convention as for how to write [about table aliases in] an SQL query&#8221; in proper sql table alias use conventions. Noach also gives us a tip: faster than [...]</description>
		<content:encoded><![CDATA[<p>[...] is no consistent convention as for how to write [about table aliases in] an SQL query&#8221; in proper sql table alias use conventions. Noach also gives us a tip: faster than [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sheeri Cabral</title>
		<link>http://code.openark.org/blog/mysql/proper-sql-table-alias-use-conventions/comment-page-1#comment-11414</link>
		<dc:creator>Sheeri Cabral</dc:creator>
		<pubDate>Fri, 12 Mar 2010 12:53:40 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=2156#comment-11414</guid>
		<description>I personally hate single or 2-character table aliases, because when using EXPLAIN, you see the table alias only......</description>
		<content:encoded><![CDATA[<p>I personally hate single or 2-character table aliases, because when using EXPLAIN, you see the table alias only......</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shlomi</title>
		<link>http://code.openark.org/blog/mysql/proper-sql-table-alias-use-conventions/comment-page-1#comment-11393</link>
		<dc:creator>shlomi</dc:creator>
		<pubDate>Fri, 12 Mar 2010 04:19:03 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=2156#comment-11393</guid>
		<description>Hi Hed,

Indeed, the XML repository makes for more readable queries, plus it concentrates queries in one place. Which is why Springframework, Ibatis etc. support and encourage XML files.
One can argue whether this is the better method. I confess I still like to see my queries next to the relevant code. But I believe this is mostly a development-tool need-to-solve problem.

Shlomi</description>
		<content:encoded><![CDATA[<p>Hi Hed,</p>
<p>Indeed, the XML repository makes for more readable queries, plus it concentrates queries in one place. Which is why Springframework, Ibatis etc. support and encourage XML files.<br />
One can argue whether this is the better method. I confess I still like to see my queries next to the relevant code. But I believe this is mostly a development-tool need-to-solve problem.</p>
<p>Shlomi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hed</title>
		<link>http://code.openark.org/blog/mysql/proper-sql-table-alias-use-conventions/comment-page-1#comment-11383</link>
		<dc:creator>hed</dc:creator>
		<pubDate>Thu, 11 Mar 2010 20:19:26 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=2156#comment-11383</guid>
		<description>As the semi proud originator of the aliasing convention post. 
(not because of the well behaved queries)

I want to add
that we used to hold our queries in the Java code, and it was horrible.
most annoying was the time it took to switch from code to shell execute. (the query formatting)
So we moved to an XML repository which is much better.
Queries are much more readable and extractable.</description>
		<content:encoded><![CDATA[<p>As the semi proud originator of the aliasing convention post.<br />
(not because of the well behaved queries)</p>
<p>I want to add<br />
that we used to hold our queries in the Java code, and it was horrible.<br />
most annoying was the time it took to switch from code to shell execute. (the query formatting)<br />
So we moved to an XML repository which is much better.<br />
Queries are much more readable and extractable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shlomi</title>
		<link>http://code.openark.org/blog/mysql/proper-sql-table-alias-use-conventions/comment-page-1#comment-11378</link>
		<dc:creator>shlomi</dc:creator>
		<pubDate>Thu, 11 Mar 2010 12:08:37 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=2156#comment-11378</guid>
		<description>Hmmm... something still missing in the query...</description>
		<content:encoded><![CDATA[<p>Hmmm... something still missing in the query...</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shlomi</title>
		<link>http://code.openark.org/blog/mysql/proper-sql-table-alias-use-conventions/comment-page-1#comment-11376</link>
		<dc:creator>shlomi</dc:creator>
		<pubDate>Thu, 11 Mar 2010 11:38:54 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=2156#comment-11376</guid>
		<description>@Bill

Thank you. Yes, I completely agree. Having a convention is the most important part; I only gave my recommendations.
Indeed I did not tackle the self join issue. Thank you for your example! (I hope I fixed your code correctly?)</description>
		<content:encoded><![CDATA[<p>@Bill</p>
<p>Thank you. Yes, I completely agree. Having a convention is the most important part; I only gave my recommendations.<br />
Indeed I did not tackle the self join issue. Thank you for your example! (I hope I fixed your code correctly?)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill Karwin</title>
		<link>http://code.openark.org/blog/mysql/proper-sql-table-alias-use-conventions/comment-page-1#comment-11372</link>
		<dc:creator>Bill Karwin</dc:creator>
		<pubDate>Thu, 11 Mar 2010 09:14:43 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=2156#comment-11372</guid>
		<description>Er, part of my example query above was eaten. :(</description>
		<content:encoded><![CDATA[<p>Er, part of my example query above was eaten. <img src='http://code.openark.org/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill Karwin</title>
		<link>http://code.openark.org/blog/mysql/proper-sql-table-alias-use-conventions/comment-page-1#comment-11371</link>
		<dc:creator>Bill Karwin</dc:creator>
		<pubDate>Thu, 11 Mar 2010 09:13:33 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=2156#comment-11371</guid>
		<description>As with any other coding language, the specific details of your coding conventions are not as important as *having* coding conventions, and following them more or less consistently.

I think your recommendations are fine.  You are, however, missing any recommendations for how to name aliases when you use self-joins.

I find that sometimes, the alias may even be longer than the table name:
&lt;pre&gt;
SELECT later_customer.*
FROM 
  customers AS first_customer
  JOIN customers AS later_customer ON (first_customer.cust_id = hypothetical_earlier_customer.cust_id)
WHERE 
  hypothetical_earlier_customer.cust_id IS NULL;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>As with any other coding language, the specific details of your coding conventions are not as important as *having* coding conventions, and following them more or less consistently.</p>
<p>I think your recommendations are fine.  You are, however, missing any recommendations for how to name aliases when you use self-joins.</p>
<p>I find that sometimes, the alias may even be longer than the table name:</p>
<pre>
SELECT later_customer.*
FROM
  customers AS first_customer
  JOIN customers AS later_customer ON (first_customer.cust_id = hypothetical_earlier_customer.cust_id)
WHERE
  hypothetical_earlier_customer.cust_id IS NULL;
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>

