<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BRADINO &#187; MySQL</title>
	<atom:link href="http://www.bradino.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bradino.com</link>
	<description>LAMP Development Tutorials, Code, Tips &#38; Tricks</description>
	<lastBuildDate>Sat, 10 Oct 2009 20:49:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MySQL Query Cache</title>
		<link>http://www.bradino.com/mysql/query-cache/</link>
		<comments>http://www.bradino.com/mysql/query-cache/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 00:20:28 +0000</pubDate>
		<dc:creator>BRADINO</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.bradino.com/?p=4867</guid>
		<description><![CDATA[According to MySQL.com the query cache stores the text of a SELECT statement together with the corresponding result that was sent to the client. If an identical statement is received later, the server retrieves the results from the query cache rather than parsing and executing the statement again. The query cache is shared among sessions, [...]]]></description>
			<content:encoded><![CDATA[<p>According to <a href="http://dev.mysql.com/doc/refman/5.1/en/query-cache.html" target="blank" rel="nofollow">MySQL.com</a> the query cache stores the text of a SELECT statement together with the corresponding result that was sent to the client. If an identical statement is received later, the server retrieves the results from the query cache rather than parsing and executing the statement again. The query cache is shared among sessions, so a result set generated by one client can be sent in response to the same query issued by another client. </p>
<p>Purely hypothetical example:</p>
<div class="syntax_hilite">
<div id="sql-3">
<div class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #ff0000;">`name`</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`beers`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #ff0000;">`favorite`</span> = true</div>
</div>
</div>
<p></p>
<p>To force the database NOT to give you a cached result simply add <strong>SQL_NO_CACHE</strong> to the query:</p>
<div class="syntax_hilite">
<div id="sql-4">
<div class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> SQL_NO_CACHE <span style="color: #ff0000;">`name`</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`beers`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #ff0000;">`favorite`</span> = true</div>
</div>
</div>
<p></p>
<div class="awmp_tags"><a href="http://www.bradino.com/search/mysql query cache/" rel="tag">mysql query cache</a> <a href="http://www.bradino.com/search/sql no cache/" rel="tag">sql no cache</a> <a href="http://www.bradino.com/search/mysql nocache/" rel="tag">mysql nocache</a></div>
<div class="sociable">

<ul>
	<li><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache" title="Digg"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://twitter.com/home?status=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F" title="TwitThis"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache" title="del.icio.us"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.netvouz.com/action/submitBookmark?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache&amp;popup=no" title="Netvouz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/netvouz.png" title="Netvouz" alt="Netvouz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache" title="description"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/dzone.png" title="description" alt="description" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache" title="Reddit"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;t=MySQL%20Query%20Cache" title="Furl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;h=MySQL%20Query%20Cache" title="NewsVine"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache" title="Simpy"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/simpy.png" title="Simpy" alt="Simpy" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://slashdot.org/bookmark.pl?title=MySQL%20Query%20Cache&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F" title="Slashdot"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache" title="Spurl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache" title="StumbleUpon"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;=MySQL%20Query%20Cache" title="YahooMyWeb"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://tailrank.com/share/?text=&amp;link_href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache" title="TailRank"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/tailrank.png" title="TailRank" alt="TailRank" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F" title="Technorati"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;t=MySQL%20Query%20Cache" title="Facebook"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache" title="Google"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache&amp;source=BRADINO+LAMP+Development+Tutorials%2C+Code%2C+Tips+%26amp%3B+Tricks&amp;summary=According%20to%20MySQL.com%20the%20query%20cache%20stores%20the%20text%20of%20a%20SELECT%20statement%20together%20with%20the%20corresponding%20result%20that%20was%20sent%20to%20the%20client.%20If%20an%20identical%20statement%20is%20received%20later%2C%20the%20server%20retrieves%20the%20results%20from%20the%20query%20cache%20rather" title="LinkedIn"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache" title="Live"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;t=MySQL%20Query%20Cache" title="MySpace"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;title=MySQL%20Query%20Cache" title="Ping.fm"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/ping.gif" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F&amp;submitHeadline=MySQL%20Query%20Cache&amp;submitSummary=According%20to%20MySQL.com%20the%20query%20cache%20stores%20the%20text%20of%20a%20SELECT%20statement%20together%20with%20the%20corresponding%20result%20that%20was%20sent%20to%20the%20client.%20If%20an%20identical%20statement%20is%20received%20later%2C%20the%20server%20retrieves%20the%20results%20from%20the%20query%20cache%20rather&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoobuzz.gif" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="mailto:?subject=MySQL%20Query%20Cache&amp;body=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fquery-cache%2F" title="E-mail this story to a friend!"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bradino.com/mysql/query-cache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Count Email Address Domains</title>
		<link>http://www.bradino.com/mysql/count-email-address-domains/</link>
		<comments>http://www.bradino.com/mysql/count-email-address-domains/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 01:03:16 +0000</pubDate>
		<dc:creator>BRADINO</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.bradino.com/?p=4861</guid>
		<description><![CDATA[A quick tidbit I came up with today to count email addresses in a mysql database table grouping them by domain. So say for example you have a large list of subscribers and you want to see the breakdown of people who use Hotmail, Yahoo, Gmail, etc.


SELECT COUNT&#40; SUBSTRING_INDEX&#40; `email` , '@', -1 &#41; &#41; [...]]]></description>
			<content:encoded><![CDATA[<p>A quick tidbit I came up with today to count email addresses in a mysql database table grouping them by domain. So say for example you have a large list of subscribers and you want to see the breakdown of people who use Hotmail, Yahoo, Gmail, etc.</p>
<div class="syntax_hilite">
<div id="sql-6">
<div class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> COUNT<span style="color:#006600; font-weight:bold;">&#40;</span> SUBSTRING_INDEX<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color: #ff0000;">`email`</span> , <span style="color: #ff0000;">'@'</span>, -<span style="color: #cc66cc;">1</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`count`</span> , <br />
SUBSTRING_INDEX<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color: #ff0000;">`email`</span> , <span style="color: #ff0000;">'@'</span>, -<span style="color: #cc66cc;">1</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`domain`</span><br />
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`subscribers`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #ff0000;">`email`</span> != <span style="color: #ff0000;">''</span> <br />
<span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #ff0000;">`domain`</span><br />
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #ff0000;">`count`</span> <span style="color: #993333; font-weight: bold;">DESC</span></div>
</div>
</div>
<p></p>
<p>This sql statement assumes that the table is called 'subscribers' and the column containing the email addresses is 'email'. Change these two values to match your table name and email address column name. </p>
<div class="awmp_tags"><a href="http://www.bradino.com/search/mysql count email/" rel="tag">mysql count email</a> <a href="http://www.bradino.com/search/mysql count domain/" rel="tag">mysql count domain</a> <a href="http://www.bradino.com/search/mysql split email/" rel="tag">mysql split email</a> <a href="http://www.bradino.com/search/mysql split domain/" rel="tag">mysql split domain</a></div>
<div class="sociable">

<ul>
	<li><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains" title="Digg"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://twitter.com/home?status=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F" title="TwitThis"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains" title="del.icio.us"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.netvouz.com/action/submitBookmark?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains&amp;popup=no" title="Netvouz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/netvouz.png" title="Netvouz" alt="Netvouz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains" title="description"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/dzone.png" title="description" alt="description" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains" title="Reddit"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;t=Count%20Email%20Address%20Domains" title="Furl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;h=Count%20Email%20Address%20Domains" title="NewsVine"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains" title="Simpy"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/simpy.png" title="Simpy" alt="Simpy" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://slashdot.org/bookmark.pl?title=Count%20Email%20Address%20Domains&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F" title="Slashdot"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains" title="Spurl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains" title="StumbleUpon"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;=Count%20Email%20Address%20Domains" title="YahooMyWeb"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://tailrank.com/share/?text=&amp;link_href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains" title="TailRank"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/tailrank.png" title="TailRank" alt="TailRank" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F" title="Technorati"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;t=Count%20Email%20Address%20Domains" title="Facebook"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains" title="Google"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains&amp;source=BRADINO+LAMP+Development+Tutorials%2C+Code%2C+Tips+%26amp%3B+Tricks&amp;summary=A%20quick%20tidbit%20I%20came%20up%20with%20today%20to%20count%20email%20addresses%20in%20a%20mysql%20database%20table%20grouping%20them%20by%20domain.%20So%20say%20for%20example%20you%20have%20a%20large%20list%20of%20subscribers%20and%20you%20want%20to%20see%20the%20breakdown%20of%20people%20who%20use%20Hotmail%2C%20Yahoo%2C%20Gmail%2C%20etc.%0D%0A%0D" title="LinkedIn"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains" title="Live"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;t=Count%20Email%20Address%20Domains" title="MySpace"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;title=Count%20Email%20Address%20Domains" title="Ping.fm"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/ping.gif" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F&amp;submitHeadline=Count%20Email%20Address%20Domains&amp;submitSummary=A%20quick%20tidbit%20I%20came%20up%20with%20today%20to%20count%20email%20addresses%20in%20a%20mysql%20database%20table%20grouping%20them%20by%20domain.%20So%20say%20for%20example%20you%20have%20a%20large%20list%20of%20subscribers%20and%20you%20want%20to%20see%20the%20breakdown%20of%20people%20who%20use%20Hotmail%2C%20Yahoo%2C%20Gmail%2C%20etc.%0D%0A%0D&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoobuzz.gif" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="mailto:?subject=Count%20Email%20Address%20Domains&amp;body=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcount-email-address-domains%2F" title="E-mail this story to a friend!"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bradino.com/mysql/count-email-address-domains/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Calculate Age using Date Field</title>
		<link>http://www.bradino.com/mysql/calculate-age-using-date-field/</link>
		<comments>http://www.bradino.com/mysql/calculate-age-using-date-field/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 00:45:08 +0000</pubDate>
		<dc:creator>BRADINO</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.bradino.com/?p=4833</guid>
		<description><![CDATA[So if you have a database table that has DOB borthdays as date fields, this is an easy way to query that table based on age parameters. The following examples assume that the date of birth date field is dob and the table name is people.
Find people who are 30 years old


SELECT DATE_FORMAT&#40; FROM_DAYS&#40; TO_DAYS&#40; [...]]]></description>
			<content:encoded><![CDATA[<p>So if you have a database table that has DOB borthdays as date fields, this is an easy way to query that table based on age parameters. The following examples assume that the date of birth date field is dob and the table name is people.</p>
<p>Find people who are 30 years old</p>
<div class="syntax_hilite">
<div id="sql-11">
<div class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> DATE_FORMAT<span style="color:#006600; font-weight:bold;">&#40;</span> FROM_DAYS<span style="color:#006600; font-weight:bold;">&#40;</span> TO_DAYS<span style="color:#006600; font-weight:bold;">&#40;</span> now<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> - TO_DAYS<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color: #ff0000;">`dob`</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> , <span style="color: #ff0000;">'%Y'</span> <span style="color:#006600; font-weight:bold;">&#41;</span> +<span style="color: #cc66cc;">0</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`age`</span><br />
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`people`</span> <span style="color: #993333; font-weight: bold;">HAVING</span> <span style="color: #ff0000;">`age`</span> = <span style="color: #cc66cc;">30</span></div>
</div>
</div>
<p></p>
<p>Find people who are 31-42 years old</p>
<div class="syntax_hilite">
<div id="sql-12">
<div class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> DATE_FORMAT<span style="color:#006600; font-weight:bold;">&#40;</span> FROM_DAYS<span style="color:#006600; font-weight:bold;">&#40;</span> TO_DAYS<span style="color:#006600; font-weight:bold;">&#40;</span> now<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> - TO_DAYS<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color: #ff0000;">`dob`</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> , <span style="color: #ff0000;">'%Y'</span> <span style="color:#006600; font-weight:bold;">&#41;</span> +<span style="color: #cc66cc;">0</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`age`</span><br />
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`people`</span> <span style="color: #993333; font-weight: bold;">HAVING</span> <span style="color: #ff0000;">`age`</span>&gt;= <span style="color: #cc66cc;">31</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #ff0000;">`age`</span> &lt;= <span style="color: #cc66cc;">42</span></div>
</div>
</div>
<p></p>
<p>Find oldest person</p>
<div class="syntax_hilite">
<div id="sql-13">
<div class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> MAX<span style="color:#006600; font-weight:bold;">&#40;</span>DATE_FORMAT<span style="color:#006600; font-weight:bold;">&#40;</span> FROM_DAYS<span style="color:#006600; font-weight:bold;">&#40;</span> TO_DAYS<span style="color:#006600; font-weight:bold;">&#40;</span> now<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> - TO_DAYS<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color: #ff0000;">`dob`</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> , <span style="color: #ff0000;">'%Y'</span> <span style="color:#006600; font-weight:bold;">&#41;</span> +<span style="color: #cc66cc;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`age`</span><br />
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`people`</span></div>
</div>
</div>
<p></p>
<p>Find youngest person</p>
<div class="syntax_hilite">
<div id="sql-14">
<div class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> MIN<span style="color:#006600; font-weight:bold;">&#40;</span>DATE_FORMAT<span style="color:#006600; font-weight:bold;">&#40;</span> FROM_DAYS<span style="color:#006600; font-weight:bold;">&#40;</span> TO_DAYS<span style="color:#006600; font-weight:bold;">&#40;</span> now<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> - TO_DAYS<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color: #ff0000;">`dob`</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> , <span style="color: #ff0000;">'%Y'</span> <span style="color:#006600; font-weight:bold;">&#41;</span> +<span style="color: #cc66cc;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`age`</span><br />
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`people`</span></div>
</div>
</div>
<p></p>

<div class="sociable">

<ul>
	<li><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field" title="Digg"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://twitter.com/home?status=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F" title="TwitThis"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field" title="del.icio.us"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.netvouz.com/action/submitBookmark?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field&amp;popup=no" title="Netvouz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/netvouz.png" title="Netvouz" alt="Netvouz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field" title="description"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/dzone.png" title="description" alt="description" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field" title="Reddit"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;t=Calculate%20Age%20using%20Date%20Field" title="Furl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;h=Calculate%20Age%20using%20Date%20Field" title="NewsVine"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field" title="Simpy"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/simpy.png" title="Simpy" alt="Simpy" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://slashdot.org/bookmark.pl?title=Calculate%20Age%20using%20Date%20Field&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F" title="Slashdot"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field" title="Spurl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field" title="StumbleUpon"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;=Calculate%20Age%20using%20Date%20Field" title="YahooMyWeb"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://tailrank.com/share/?text=&amp;link_href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field" title="TailRank"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/tailrank.png" title="TailRank" alt="TailRank" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F" title="Technorati"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;t=Calculate%20Age%20using%20Date%20Field" title="Facebook"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field" title="Google"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field&amp;source=BRADINO+LAMP+Development+Tutorials%2C+Code%2C+Tips+%26amp%3B+Tricks&amp;summary=So%20if%20you%20have%20a%20database%20table%20that%20has%20DOB%20borthdays%20as%20date%20fields%2C%20this%20is%20an%20easy%20way%20to%20query%20that%20table%20based%20on%20age%20parameters.%20The%20following%20examples%20assume%20that%20the%20date%20of%20birth%20date%20field%20is%20dob%20and%20the%20table%20name%20is%20people.%0D%0A%0D%0AFind%20peopl" title="LinkedIn"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field" title="Live"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;t=Calculate%20Age%20using%20Date%20Field" title="MySpace"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;title=Calculate%20Age%20using%20Date%20Field" title="Ping.fm"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/ping.gif" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F&amp;submitHeadline=Calculate%20Age%20using%20Date%20Field&amp;submitSummary=So%20if%20you%20have%20a%20database%20table%20that%20has%20DOB%20borthdays%20as%20date%20fields%2C%20this%20is%20an%20easy%20way%20to%20query%20that%20table%20based%20on%20age%20parameters.%20The%20following%20examples%20assume%20that%20the%20date%20of%20birth%20date%20field%20is%20dob%20and%20the%20table%20name%20is%20people.%0D%0A%0D%0AFind%20peopl&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoobuzz.gif" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="mailto:?subject=Calculate%20Age%20using%20Date%20Field&amp;body=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fcalculate-age-using-date-field%2F" title="E-mail this story to a friend!"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bradino.com/mysql/calculate-age-using-date-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL SELECT WHERE IN</title>
		<link>http://www.bradino.com/mysql/select-where-in/</link>
		<comments>http://www.bradino.com/mysql/select-where-in/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 18:33:03 +0000</pubDate>
		<dc:creator>BRADINO</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.bradino.com/?p=4786</guid>
		<description><![CDATA[Here is a basic sql statement where you are looking for shirts that are red, white or blue.


SELECT * FROM `shirts` WHERE `color`='red' OR `color`='white' OR `color`='blue'



Here is the same request, more efficiently constructed using IN


SELECT * FROM `shirts` WHERE `color` IN &#40;'red','white','blue'&#41;



If you are like me and dynamically create SQL statements using PHP then [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a basic sql statement where you are looking for shirts that are red, white or blue.</p>
<div class="syntax_hilite">
<div id="mysql-18">
<div class="mysql"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> `shirts` <span style="color: #993333; font-weight: bold;">WHERE</span> `color`=<span style="color: #ff0000;">'red'</span> OR `color`=<span style="color: #ff0000;">'white'</span> OR `color`=<span style="color: #ff0000;">'blue'</span></div>
</div>
</div>
<p></p>
<p>Here is the same request, more efficiently constructed using IN</p>
<div class="syntax_hilite">
<div id="mysql-19">
<div class="mysql"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> `shirts` <span style="color: #993333; font-weight: bold;">WHERE</span> `color` IN <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'red'</span>,<span style="color: #ff0000;">'white'</span>,<span style="color: #ff0000;">'blue'</span><span style="color: #66cc66;">&#41;</span></div>
</div>
</div>
<p></p>
<p>If you are like me and dynamically create SQL statements using PHP then you get the idea of how easy it would be to create this statement. Let's say you have an array of possible value.</p>
<div class="syntax_hilite">
<div id="php-20">
<div class="php"><span style="color:#0000FF;">$colors</span> = <a href="http://www.bradino.com/php-functions/array/"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'red'</span>,<span style="color:#FF0000;">'white'</span>,<span style="color:#FF0000;">'blue'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"SELECT * FROM `shirts` WHERE `color` IN ('"</span> . <a href="http://www.bradino.com/php-functions/implode/"><span style="color:#000066;">implode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"','"</span>, <span style="color:#0000FF;">$colors</span><span style="color:#006600; font-weight:bold;">&#41;</span> . <span style="color:#FF0000;">"')"</span> ;</div>
</div>
</div>
<p></p>
<div class="awmp_tags"><a href="http://www.bradino.com/search/mysql select in/" rel="tag">mysql select in</a> <a href="http://www.bradino.com/search/select in/" rel="tag">select in</a> <a href="http://www.bradino.com/search/where select in/" rel="tag">where select in</a></div>
<div class="sociable">

<ul>
	<li><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN" title="Digg"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://twitter.com/home?status=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F" title="TwitThis"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN" title="del.icio.us"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.netvouz.com/action/submitBookmark?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN&amp;popup=no" title="Netvouz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/netvouz.png" title="Netvouz" alt="Netvouz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN" title="description"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/dzone.png" title="description" alt="description" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN" title="Reddit"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;t=SQL%20SELECT%20WHERE%20IN" title="Furl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;h=SQL%20SELECT%20WHERE%20IN" title="NewsVine"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN" title="Simpy"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/simpy.png" title="Simpy" alt="Simpy" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://slashdot.org/bookmark.pl?title=SQL%20SELECT%20WHERE%20IN&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F" title="Slashdot"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN" title="Spurl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN" title="StumbleUpon"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;=SQL%20SELECT%20WHERE%20IN" title="YahooMyWeb"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://tailrank.com/share/?text=&amp;link_href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN" title="TailRank"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/tailrank.png" title="TailRank" alt="TailRank" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F" title="Technorati"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;t=SQL%20SELECT%20WHERE%20IN" title="Facebook"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN" title="Google"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN&amp;source=BRADINO+LAMP+Development+Tutorials%2C+Code%2C+Tips+%26amp%3B+Tricks&amp;summary=Here%20is%20a%20basic%20sql%20statement%20where%20you%20are%20looking%20for%20shirts%20that%20are%20red%2C%20white%20or%20blue.%0D%0A%0D%0A%5Bmysql%5DSELECT%20%2A%20FROM%20%60shirts%60%20WHERE%20%60color%60%3D%27red%27%20OR%20%60color%60%3D%27white%27%20OR%20%60color%60%3D%27blue%27%5B%2Fmysql%5D%0D%0A%0D%0AHere%20is%20the%20same%20request%2C%20more%20efficiently%20constructed%20us" title="LinkedIn"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN" title="Live"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;t=SQL%20SELECT%20WHERE%20IN" title="MySpace"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;title=SQL%20SELECT%20WHERE%20IN" title="Ping.fm"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/ping.gif" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F&amp;submitHeadline=SQL%20SELECT%20WHERE%20IN&amp;submitSummary=Here%20is%20a%20basic%20sql%20statement%20where%20you%20are%20looking%20for%20shirts%20that%20are%20red%2C%20white%20or%20blue.%0D%0A%0D%0A%5Bmysql%5DSELECT%20%2A%20FROM%20%60shirts%60%20WHERE%20%60color%60%3D%27red%27%20OR%20%60color%60%3D%27white%27%20OR%20%60color%60%3D%27blue%27%5B%2Fmysql%5D%0D%0A%0D%0AHere%20is%20the%20same%20request%2C%20more%20efficiently%20constructed%20us&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoobuzz.gif" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="mailto:?subject=SQL%20SELECT%20WHERE%20IN&amp;body=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fselect-where-in%2F" title="E-mail this story to a friend!"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bradino.com/mysql/select-where-in/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple MySQL Database Backup</title>
		<link>http://www.bradino.com/mysql/simple-mysql-database-backup/</link>
		<comments>http://www.bradino.com/mysql/simple-mysql-database-backup/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 23:31:56 +0000</pubDate>
		<dc:creator>BRADINO</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.bradino.com/?p=4771</guid>
		<description><![CDATA[This is the simplest way to backup MySQL databases and tables using the mysqldump command to generate an sql file. I will also show you how to restore the database or table from the generated sql file and demonstrate a simple loop to generate a separate mysqldump of each table in a given database. This [...]]]></description>
			<content:encoded><![CDATA[<p>This is the simplest way to backup MySQL databases and tables using the mysqldump command to generate an sql file. I will also show you how to restore the database or table from the generated sql file and demonstrate a simple loop to generate a separate mysqldump of each table in a given database. This makes it really easy to restore just the table(s) that you want.</p>
<p>So first let's setup some global variables we will use later with some simple function calls. Database Host, database Name, Database User, Password and Path. Important to remember, Path needs to be writable by PHP and also be sure to escape and weird characters like $ in the fields.</p>
<div class="syntax_hilite">
<div id="php-32">
<div class="php"><span style="color:#FF9933; font-style:italic;">// SETUP GLOBAL PARAMETERS</span></p>
<p><span style="color:#0000FF;">$params</span> = <a href="http://www.bradino.com/php-functions/array/"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'host'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#FF0000;">'localhost'</span>;</p>
<p><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'database'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#FF0000;">'collections'</span>;</p>
<p><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'username'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#FF0000;">'user007'</span>;</p>
<p><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'password'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#FF0000;">'asdf123'</span>;</p>
<p><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'table'</span><span style="color:#006600; font-weight:bold;">&#93;</span>&nbsp; = <span style="color:#FF0000;">'widgets'</span>;</p>
<p><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'path'</span><span style="color:#006600; font-weight:bold;">&#93;</span>&nbsp; = <span style="color:#FF0000;">'PATH/backup/'</span>;</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="php-33">
<div class="php"><span style="color:#FF9933; font-style:italic;">// BACKUP A SINGLE TABLE</span></p>
<p>mysqlBackupTable<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="php-34">
<div class="php"><span style="color:#FF9933; font-style:italic;">// BACKUP AN ENTIRE DATABASE</span></p>
<p>mysqlBackupDatabase<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="php-35">
<div class="php"><span style="color:#FF9933; font-style:italic;">// RESTORE TABLE</span></p>
<p>mysqlRestoreTable<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="php-36">
<div class="php"><span style="color:#FF9933; font-style:italic;">// RESTORE DATABASE</span></p>
<p>mysqlRestoreDatabase<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="php-37">
<div class="php"><span style="color:#FF9933; font-style:italic;">// BACKUP ALL TABLES IN A DATABASE</span></p>
<p><span style="color:#0000FF;">$query</span> = <a href="http://www.bradino.com/php-functions/mysql_query/"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"SHOW TABLES FROM `{$params['database']}`"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><span style="color:#616100;">while</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$row</span> = <a href="http://www.bradino.com/php-functions/mysql_fetch_row/"><span style="color:#000066;">mysql_fetch_row</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$query</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'table'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$row</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; mysqlBackupTable<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; <br />
&nbsp; &nbsp; <br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="php-38">
<div class="php"><span style="color:#FF9933; font-style:italic;">// FUNCTION: BACKUP MYSQL TABLE TO A FILE</span></p>
<p><span style="color:#000000; font-weight:bold;">function</span> mysqlBackupTable<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color:#0000FF;">$outfile</span> = makeFileName<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'path'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'database'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'table'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span style="color:#0000FF;">$cmd</span> = <span style="color:#FF0000;">"mysqldump --user={$params['username']} --password={$params['password']} {$params['database']} --tables {$params['table']}&gt; {$outfile}"</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <a href="http://www.bradino.com/php-functions/system/"><span style="color:#000066;">system</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$cmd</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="php-39">
<div class="php"><span style="color:#FF9933; font-style:italic;">// FUNCTION: BACKUP MYSQL DATABASE TO A FILE</span></p>
<p><span style="color:#000000; font-weight:bold;">function</span> mysqlBackupDatabase<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color:#0000FF;">$outfile</span> = makeFileName<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'path'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'database'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p>&nbsp; &nbsp; <span style="color:#0000FF;">$cmd</span> = <span style="color:#FF0000;">"mysqldump --user={$params['username']} --password={$params['password']} {$params['database']}&gt; {$outfile}"</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <a href="http://www.bradino.com/php-functions/system/"><span style="color:#000066;">system</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$cmd</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="php-40">
<div class="php"><span style="color:#FF9933; font-style:italic;">// FUNCTION: RESTORE MYSQL TABLE</span></p>
<p><span style="color:#000000; font-weight:bold;">function</span> mysqlRestoreTable<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color:#0000FF;">$infile</span> = makeFileName<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'path'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'database'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'table'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color:#0000FF;">$cmd</span> = <span style="color:#FF0000;">"mysql --user={$params['username']} --password={$params['password']} {$params['database']} &lt;{$infile}"</span>;</p>
<p>&nbsp; &nbsp; <a href="http://www.bradino.com/php-functions/system/"><span style="color:#000066;">system</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$cmd</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="php-41">
<div class="php"><span style="color:#FF9933; font-style:italic;">// FUNCTION: RESTORE MYSQL DATABASE</span></p>
<p><span style="color:#000000; font-weight:bold;">function</span> mysqlRestoreDatabase<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color:#0000FF;">$infile</span> = makeFileName<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'path'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'database'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color:#0000FF;">$cmd</span> = <span style="color:#FF0000;">"mysql --user={$params['username']} --password={$params['password']} {$params['database']} &lt;{$infile}"</span>;</p>
<p>&nbsp; &nbsp; <a href="http://www.bradino.com/php-functions/system/"><span style="color:#000066;">system</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$cmd</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="php-42">
<div class="php"><span style="color:#FF9933; font-style:italic;">// FUNCTION: NAMING CONVENTION FOR DUMP FILES</span></p>
<p><span style="color:#000000; font-weight:bold;">function</span> makeFileName<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$path</span>,<span style="color:#0000FF;">$database</span>,<span style="color:#0000FF;">$table</span>=<span style="color:#FF0000;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.bradino.com/php-functions/empty/"><span style="color:#000066;">empty</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$table</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#FF0000;">"{$path}{$database}@{$table}.sql"</span> : <span style="color:#FF0000;">"{$path}{$database}.sql"</span> ;<br />
&nbsp; &nbsp; <br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<div class="awmp_tags"><a href="http://www.bradino.com/search/php mysql backup/" rel="tag">php mysql backup</a> <a href="http://www.bradino.com/search/mysql backup/" rel="tag">mysql backup</a> <a href="http://www.bradino.com/search/mysqldump php/" rel="tag">mysqldump php</a> <a href="http://www.bradino.com/search/mysqldump restore/" rel="tag">mysqldump restore</a> <a href="http://www.bradino.com/search/restore mysql database/" rel="tag">restore mysql database</a></div>
<div class="sociable">

<ul>
	<li><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup" title="Digg"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://twitter.com/home?status=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F" title="TwitThis"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup" title="del.icio.us"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.netvouz.com/action/submitBookmark?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup&amp;popup=no" title="Netvouz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/netvouz.png" title="Netvouz" alt="Netvouz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup" title="description"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/dzone.png" title="description" alt="description" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup" title="Reddit"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;t=Simple%20MySQL%20Database%20Backup" title="Furl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;h=Simple%20MySQL%20Database%20Backup" title="NewsVine"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup" title="Simpy"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/simpy.png" title="Simpy" alt="Simpy" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://slashdot.org/bookmark.pl?title=Simple%20MySQL%20Database%20Backup&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F" title="Slashdot"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup" title="Spurl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup" title="StumbleUpon"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;=Simple%20MySQL%20Database%20Backup" title="YahooMyWeb"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://tailrank.com/share/?text=&amp;link_href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup" title="TailRank"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/tailrank.png" title="TailRank" alt="TailRank" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F" title="Technorati"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;t=Simple%20MySQL%20Database%20Backup" title="Facebook"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup" title="Google"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup&amp;source=BRADINO+LAMP+Development+Tutorials%2C+Code%2C+Tips+%26amp%3B+Tricks&amp;summary=This%20is%20the%20simplest%20way%20to%20backup%20MySQL%20databases%20and%20tables%20using%20the%20mysqldump%20command%20to%20generate%20an%20sql%20file.%20I%20will%20also%20show%20you%20how%20to%20restore%20the%20database%20or%20table%20from%20the%20generated%20sql%20file%20and%20demonstrate%20a%20simple%20loop%20to%20generate%20a%20separ" title="LinkedIn"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup" title="Live"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;t=Simple%20MySQL%20Database%20Backup" title="MySpace"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;title=Simple%20MySQL%20Database%20Backup" title="Ping.fm"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/ping.gif" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F&amp;submitHeadline=Simple%20MySQL%20Database%20Backup&amp;submitSummary=This%20is%20the%20simplest%20way%20to%20backup%20MySQL%20databases%20and%20tables%20using%20the%20mysqldump%20command%20to%20generate%20an%20sql%20file.%20I%20will%20also%20show%20you%20how%20to%20restore%20the%20database%20or%20table%20from%20the%20generated%20sql%20file%20and%20demonstrate%20a%20simple%20loop%20to%20generate%20a%20separ&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoobuzz.gif" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="mailto:?subject=Simple%20MySQL%20Database%20Backup&amp;body=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fsimple-mysql-database-backup%2F" title="E-mail this story to a friend!"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bradino.com/mysql/simple-mysql-database-backup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Zipcode Radius Search</title>
		<link>http://www.bradino.com/mysql/zipcode-radius-search/</link>
		<comments>http://www.bradino.com/mysql/zipcode-radius-search/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 20:55:42 +0000</pubDate>
		<dc:creator>BRADINO</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.bradino.com/?p=4749</guid>
		<description><![CDATA[Want to find all zipcodes and corresponding distances within a certain mile/kilometer radius from another zipcode or point? This problems require latitude and longitude coordinates to solve. Geocoding the address gives you latitude/longitude coordinates from an address. Both Yahoo and Google offer free geocoding services. I wrote a post about geocoding with a code example [...]]]></description>
			<content:encoded><![CDATA[<p>Want to find all zipcodes and corresponding distances within a certain mile/kilometer radius from another zipcode or point? This problems require latitude and longitude coordinates to solve. Geocoding the address gives you latitude/longitude coordinates from an address. Both Yahoo and Google offer free geocoding services. I wrote a post about <a href="http://www.bradino.com/php/geocoding-location-latitude-longitude/">geocoding with a code example</a> for both Google and Yahoo geocode services.</p>
<p>First you will need a database of all zipcodes and their corresponding latitude and longitude coordinates. If you are reading this post, you probably don't have this so let me help you out. <a href="http://www.bradino.com/downloads/zipcodes.zip">Download Zipcode Database</a> for a zip file of both an SQL data dump and CSV format. Here is the basic table structure I use in my example code:</p>
<div class="syntax_hilite">
<div id="sql-45">
<div class="sql"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`zipcodes`</span> <span style="color:#006600; font-weight:bold;">&#40;</span><br />
&nbsp; <span style="color: #ff0000;">`zipcode`</span> varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span>,<br />
&nbsp; <span style="color: #ff0000;">`city`</span> varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span>,<br />
&nbsp; <span style="color: #ff0000;">`state`</span> char<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span>,<br />
&nbsp; <span style="color: #ff0000;">`latitude`</span> varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;">20</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span>,<br />
&nbsp; <span style="color: #ff0000;">`longitude`</span> varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;">20</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span>,<br />
&nbsp; <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #ff0000;">`zipcode`</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">`zipcode`</span><span style="color:#006600; font-weight:bold;">&#41;</span>,<br />
&nbsp; <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #ff0000;">`state`</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">`state`</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</div>
</div>
<p></p>
<p>So once you have the database you want to find all zipcodes within a certain mile radius of a central point. If the central point is another zipcode, simply query the database for the latitude and longitude coordinates of that zipcode. Then the code is as follows:</p>
<div class="syntax_hilite">
<div id="php-46">
<div class="php"><span style="color:#FF9933; font-style:italic;">// ITITIAL POINT</span></p>
<p><span style="color:#0000FF;">$coords</span> = <a href="http://www.bradino.com/php-functions/array/"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'latitude'</span> =&gt; <span style="color:#FF0000;">"32.8"</span>, <span style="color:#FF0000;">'longitude'</span> =&gt; <span style="color:#FF0000;">"-117.17"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p>
<span style="color:#FF9933; font-style:italic;">//RADIUS</span></p>
<p><span style="color:#0000FF;">$radius</span> = <span style="color:#CC66CC;">30</span>;</p>
<p>
<span style="color:#FF9933; font-style:italic;">// SQL FOR KILOMETERS</span></p>
<p><span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"SELECT zipcode, ( 6371 * acos( cos( radians( {$coords['latitude']} ) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians( {$coords['longitude']} ) ) + sin( radians( {$coords['latitude']} ) ) * sin( radians( latitude ) ) ) ) AS distance FROM zipcodes HAVING distance &lt;= {$radius} ORDER BY distance"</span>;</p>
<p>
<span style="color:#FF9933; font-style:italic;">// SQL FOR MILES</span></p>
<p><span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"SELECT zipcode, ( 3959 * acos( cos( radians( {$coords['latitude']} ) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians( {$coords['longitude']} ) ) + sin( radians( {$coords['latitude']} ) ) * sin( radians( latitude ) ) ) ) AS distance FROM zipcodes HAVING distance &lt;= {$radius} ORDER BY distance"</span>;</p>
<p>
<span style="color:#FF9933; font-style:italic;">// OUTPUT THE ZIPCODES AND DISTANCES</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color:#0000FF;">$query</span> = <a href="http://www.bradino.com/php-functions/mysql_query/"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><span style="color:#616100;">while</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$row</span> = <a href="http://www.bradino.com/php-functions/mysql_fetch_assoc/"><span style="color:#000066;">mysql_fetch_assoc</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$query</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <a href="http://www.bradino.com/php-functions/echo/"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">"{$row['zipcode']} ({$row['distance']})&lt;br&gt;<span style="color:#000099; font-weight:bold;">\n</span>"</span>;</p>
<p><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<div class="awmp_tags"><a href="http://www.bradino.com/search/zipcode radius/" rel="tag">zipcode radius</a> <a href="http://www.bradino.com/search/zipcode distance/" rel="tag">zipcode distance</a> <a href="http://www.bradino.com/search/geolocation radius/" rel="tag">geolocation radius</a> <a href="http://www.bradino.com/search/geolocation distance/" rel="tag">geolocation distance</a></div>
<div class="sociable">

<ul>
	<li><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search" title="Digg"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://twitter.com/home?status=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F" title="TwitThis"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search" title="del.icio.us"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.netvouz.com/action/submitBookmark?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search&amp;popup=no" title="Netvouz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/netvouz.png" title="Netvouz" alt="Netvouz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search" title="description"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/dzone.png" title="description" alt="description" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search" title="Reddit"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;t=Zipcode%20Radius%20Search" title="Furl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;h=Zipcode%20Radius%20Search" title="NewsVine"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search" title="Simpy"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/simpy.png" title="Simpy" alt="Simpy" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://slashdot.org/bookmark.pl?title=Zipcode%20Radius%20Search&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F" title="Slashdot"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search" title="Spurl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search" title="StumbleUpon"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;=Zipcode%20Radius%20Search" title="YahooMyWeb"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://tailrank.com/share/?text=&amp;link_href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search" title="TailRank"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/tailrank.png" title="TailRank" alt="TailRank" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F" title="Technorati"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;t=Zipcode%20Radius%20Search" title="Facebook"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search" title="Google"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search&amp;source=BRADINO+LAMP+Development+Tutorials%2C+Code%2C+Tips+%26amp%3B+Tricks&amp;summary=Want%20to%20find%20all%20zipcodes%20and%20corresponding%20distances%20within%20a%20certain%20mile%2Fkilometer%20radius%20from%20another%20zipcode%20or%20point%3F%20This%20problems%20require%20latitude%20and%20longitude%20coordinates%20to%20solve.%20Geocoding%20the%20address%20gives%20you%20latitude%2Flongitude%20coordina" title="LinkedIn"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search" title="Live"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;t=Zipcode%20Radius%20Search" title="MySpace"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;title=Zipcode%20Radius%20Search" title="Ping.fm"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/ping.gif" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F&amp;submitHeadline=Zipcode%20Radius%20Search&amp;submitSummary=Want%20to%20find%20all%20zipcodes%20and%20corresponding%20distances%20within%20a%20certain%20mile%2Fkilometer%20radius%20from%20another%20zipcode%20or%20point%3F%20This%20problems%20require%20latitude%20and%20longitude%20coordinates%20to%20solve.%20Geocoding%20the%20address%20gives%20you%20latitude%2Flongitude%20coordina&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoobuzz.gif" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="mailto:?subject=Zipcode%20Radius%20Search&amp;body=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fzipcode-radius-search%2F" title="E-mail this story to a friend!"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bradino.com/mysql/zipcode-radius-search/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Dayparting on Datetime Field using Substring</title>
		<link>http://www.bradino.com/mysql/dayparting-on-datetime-field-using-substring/</link>
		<comments>http://www.bradino.com/mysql/dayparting-on-datetime-field-using-substring/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 17:26:16 +0000</pubDate>
		<dc:creator>BRADINO</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.bradino.com/mysql/dayparting-on-datetime-field-using-substring/</guid>
		<description><![CDATA[Today I needed a quick and easy way to count the number of records for each of the 24 hours in a day for records in a mysql database that has a datetime field. I came up with the following query to solve that problem:


SELECT count&#40; SUBSTRING&#40; `datetime` , 12, 2 &#41; &#41; AS `num` [...]]]></description>
			<content:encoded><![CDATA[<p>Today I needed a quick and easy way to count the number of records for each of the 24 hours in a day for records in a mysql database that has a datetime field. I came up with the following query to solve that problem:</p>
<div class="syntax_hilite">
<div id="sql-48">
<div class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> count<span style="color:#006600; font-weight:bold;">&#40;</span> SUBSTRING<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color: #ff0000;">`datetime`</span> , <span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">2</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`num`</span> , SUBSTRING<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color: #ff0000;">`datetime`</span> , <span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">2</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`hour`</span><br />
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`table`</span><br />
<span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> SUBSTRING<span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color: #ff0000;">`datetime`</span> , <span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">2</span> <span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #ff0000;">`num`</span> <span style="color: #993333; font-weight: bold;">DESC</span></div>
</div>
</div>
<p></p>
<div class="awmp_tags"><a href="http://www.bradino.com/search/mysql/" rel="tag">mysql</a> <a href="http://www.bradino.com/search/dayparting/" rel="tag">dayparting</a> <a href="http://www.bradino.com/search/substring/" rel="tag">substring</a> <a href="http://www.bradino.com/search/hour counts/" rel="tag">hour counts</a></div>
<div class="sociable">

<ul>
	<li><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="Digg"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://twitter.com/home?status=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F" title="TwitThis"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="del.icio.us"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.netvouz.com/action/submitBookmark?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring&amp;popup=no" title="Netvouz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/netvouz.png" title="Netvouz" alt="Netvouz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="description"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/dzone.png" title="description" alt="description" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="Reddit"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;t=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="Furl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;h=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="NewsVine"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="Simpy"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/simpy.png" title="Simpy" alt="Simpy" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://slashdot.org/bookmark.pl?title=Dayparting%20on%20Datetime%20Field%20using%20Substring&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F" title="Slashdot"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="Spurl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="StumbleUpon"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="YahooMyWeb"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://tailrank.com/share/?text=&amp;link_href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="TailRank"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/tailrank.png" title="TailRank" alt="TailRank" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F" title="Technorati"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;t=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="Facebook"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="Google"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring&amp;source=BRADINO+LAMP+Development+Tutorials%2C+Code%2C+Tips+%26amp%3B+Tricks&amp;summary=Today%20I%20needed%20a%20quick%20and%20easy%20way%20to%20count%20the%20number%20of%20records%20for%20each%20of%20the%2024%20hours%20in%20a%20day%20for%20records%20in%20a%20mysql%20database%20that%20has%20a%20datetime%20field.%20I%20came%20up%20with%20the%20following%20query%20to%20solve%20that%20problem%3A%0D%0A%0D%0A%5Bsql%5D%0D%0ASELECT%20count%28%20SUBSTRIN" title="LinkedIn"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="Live"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;t=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="MySpace"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;title=Dayparting%20on%20Datetime%20Field%20using%20Substring" title="Ping.fm"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/ping.gif" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F&amp;submitHeadline=Dayparting%20on%20Datetime%20Field%20using%20Substring&amp;submitSummary=Today%20I%20needed%20a%20quick%20and%20easy%20way%20to%20count%20the%20number%20of%20records%20for%20each%20of%20the%2024%20hours%20in%20a%20day%20for%20records%20in%20a%20mysql%20database%20that%20has%20a%20datetime%20field.%20I%20came%20up%20with%20the%20following%20query%20to%20solve%20that%20problem%3A%0D%0A%0D%0A%5Bsql%5D%0D%0ASELECT%20count%28%20SUBSTRIN&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoobuzz.gif" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="mailto:?subject=Dayparting%20on%20Datetime%20Field%20using%20Substring&amp;body=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fdayparting-on-datetime-field-using-substring%2F" title="E-mail this story to a friend!"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bradino.com/mysql/dayparting-on-datetime-field-using-substring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Order By Numeric Difference</title>
		<link>http://www.bradino.com/mysql/order-by-numeric-difference/</link>
		<comments>http://www.bradino.com/mysql/order-by-numeric-difference/#comments</comments>
		<pubDate>Fri, 09 Nov 2007 22:19:58 +0000</pubDate>
		<dc:creator>BRADINO</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.bradino.com/mysql/order-by-numeric-difference/</guid>
		<description><![CDATA[A nice way I found to use MySQL to order a result set by the absolute value of the numeric difference between two numbers, where one is the value in a column. I had never used SQL to subtract two numbers, let alone take the absolute value and use that to order the results. You [...]]]></description>
			<content:encoded><![CDATA[<p>A nice way I found to use MySQL to order a result set by the absolute value of the numeric difference between two numbers, where one is the value in a column. I had never used SQL to subtract two numbers, let alone take the absolute value and use that to order the results. You could use something like this to show numbers that are most closely related, maybe in a zipcode application or a priority scoring application.</p>
<div class="syntax_hilite">
<div id="sql-50">
<div class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`table`</span> <br />
<span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #ff0000;">`something`</span>=<span style="color: #ff0000;">`whatever`</span> <br />
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> ABS <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color: #cc66cc;">711</span> - <span style="color: #ff0000;">`num`</span> <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</div>
</div>
<p></p>
<div class="awmp_tags"><a href="http://www.bradino.com/search/mysql order by/" rel="tag">mysql order by</a> <a href="http://www.bradino.com/search/mysql difference/" rel="tag">mysql difference</a> <a href="http://www.bradino.com/search/mysql subtract/" rel="tag">mysql subtract</a> <a href="http://www.bradino.com/search/mysql minus/" rel="tag">mysql minus</a> <a href="http://www.bradino.com/search/mysql absolute value/" rel="tag">mysql absolute value</a></div>
<div class="sociable">

<ul>
	<li><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference" title="Digg"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://twitter.com/home?status=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F" title="TwitThis"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference" title="del.icio.us"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.netvouz.com/action/submitBookmark?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference&amp;popup=no" title="Netvouz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/netvouz.png" title="Netvouz" alt="Netvouz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference" title="description"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/dzone.png" title="description" alt="description" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference" title="Reddit"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;t=MySQL%20Order%20By%20Numeric%20Difference" title="Furl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;h=MySQL%20Order%20By%20Numeric%20Difference" title="NewsVine"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference" title="Simpy"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/simpy.png" title="Simpy" alt="Simpy" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://slashdot.org/bookmark.pl?title=MySQL%20Order%20By%20Numeric%20Difference&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F" title="Slashdot"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference" title="Spurl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference" title="StumbleUpon"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;=MySQL%20Order%20By%20Numeric%20Difference" title="YahooMyWeb"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://tailrank.com/share/?text=&amp;link_href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference" title="TailRank"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/tailrank.png" title="TailRank" alt="TailRank" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F" title="Technorati"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;t=MySQL%20Order%20By%20Numeric%20Difference" title="Facebook"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference" title="Google"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference&amp;source=BRADINO+LAMP+Development+Tutorials%2C+Code%2C+Tips+%26amp%3B+Tricks&amp;summary=A%20nice%20way%20I%20found%20to%20use%20MySQL%20to%20order%20a%20result%20set%20by%20the%20absolute%20value%20of%20the%20numeric%20difference%20between%20two%20numbers%2C%20where%20one%20is%20the%20value%20in%20a%20column.%20I%20had%20never%20used%20SQL%20to%20subtract%20two%20numbers%2C%20let%20alone%20take%20the%20absolute%20value%20and%20use%20tha" title="LinkedIn"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference" title="Live"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;t=MySQL%20Order%20By%20Numeric%20Difference" title="MySpace"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;title=MySQL%20Order%20By%20Numeric%20Difference" title="Ping.fm"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/ping.gif" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F&amp;submitHeadline=MySQL%20Order%20By%20Numeric%20Difference&amp;submitSummary=A%20nice%20way%20I%20found%20to%20use%20MySQL%20to%20order%20a%20result%20set%20by%20the%20absolute%20value%20of%20the%20numeric%20difference%20between%20two%20numbers%2C%20where%20one%20is%20the%20value%20in%20a%20column.%20I%20had%20never%20used%20SQL%20to%20subtract%20two%20numbers%2C%20let%20alone%20take%20the%20absolute%20value%20and%20use%20tha&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoobuzz.gif" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="mailto:?subject=MySQL%20Order%20By%20Numeric%20Difference&amp;body=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Forder-by-numeric-difference%2F" title="E-mail this story to a friend!"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bradino.com/mysql/order-by-numeric-difference/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Make CSV File from Database</title>
		<link>http://www.bradino.com/mysql/make-csv-file-from-database/</link>
		<comments>http://www.bradino.com/mysql/make-csv-file-from-database/#comments</comments>
		<pubDate>Tue, 23 Oct 2007 19:44:23 +0000</pubDate>
		<dc:creator>BRADINO</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.bradino.com/php/make-csv-file-from-database/</guid>
		<description><![CDATA[This is the easiest way to make a CSV file from a database query and output it to the user for download. This simple code uses the PHP5 fputcsv function to correctly format an array of values into a line in a csv file. It does not use the physical file so you do not [...]]]></description>
			<content:encoded><![CDATA[<p>This is the easiest way to make a CSV file from a database query and output it to the user for download. This simple code uses the PHP5 fputcsv function to correctly format an array of values into a line in a csv file. It does not use the physical file so you do not need any write permissions where you use this code, as it uses the memory buffer instead.</p>
<div class="syntax_hilite">
<div id="php-52">
<div class="php"><span style="color:#0000FF;">$output</span> = <a href="http://www.bradino.com/php-functions/fopen/"><span style="color:#000066;">fopen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'php://temp/maxmemory:'</span>. <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;">5</span>*<span style="color:#CC66CC;">1024</span>*<span style="color:#CC66CC;">1024</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#FF0000;">'r+'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><span style="color:#0000FF;">$columns</span> = <a href="http://www.bradino.com/php-functions/array/"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Field1'</span>,<span style="color:#FF0000;">'Field2'</span>,<span style="color:#FF0000;">'Field3'</span>,<span style="color:#FF0000;">'Field4'</span>,<span style="color:#FF0000;">'Field5'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p>fputcsv<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$output</span>, <span style="color:#0000FF;">$columns</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><span style="color:#0000FF;">$query</span> = <a href="http://www.bradino.com/php-functions/mysql_query/"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"SELECT * FROM `table`"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><span style="color:#616100;">while</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$data</span> = <a href="http://www.bradino.com/php-functions/mysql_fetch_assoc/"><span style="color:#000066;">mysql_fetch_assoc</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$query</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; fputcsv<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$output</span>, <span style="color:#0000FF;">$data</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span></p>
<p><a href="http://www.bradino.com/php-functions/rewind/"><span style="color:#000066;">rewind</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$output</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><span style="color:#0000FF;">$export</span> = stream_get_contents<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$output</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><a href="http://www.bradino.com/php-functions/fclose/"><span style="color:#000066;">fclose</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$output</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><a href="http://www.bradino.com/php-functions/header/"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Content-type: application/octet-stream'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</p>
<p><a href="http://www.bradino.com/php-functions/header/"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Content-Disposition: attachment; filename=&quot;export.csv&quot;'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
<a href="http://www.bradino.com/php-functions/echo/"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$export</span>;</div>
</div>
</div>
<p></p>
<div class="awmp_tags"><a href="http://www.bradino.com/search/php/" rel="tag">php</a> <a href="http://www.bradino.com/search/csv file/" rel="tag">csv file</a> <a href="http://www.bradino.com/search/fputcsv function/" rel="tag">fputcsv function</a> <a href="http://www.bradino.com/search/php csv/" rel="tag">php csv</a> <a href="http://www.bradino.com/search/php spreadsheet/" rel="tag">php spreadsheet</a> <a href="http://www.bradino.com/search/pgp export database/" rel="tag">pgp export database</a></div>
<div class="sociable">

<ul>
	<li><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database" title="Digg"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://twitter.com/home?status=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F" title="TwitThis"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database" title="del.icio.us"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.netvouz.com/action/submitBookmark?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database&amp;popup=no" title="Netvouz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/netvouz.png" title="Netvouz" alt="Netvouz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database" title="description"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/dzone.png" title="description" alt="description" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database" title="Reddit"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;t=Make%20CSV%20File%20from%20Database" title="Furl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;h=Make%20CSV%20File%20from%20Database" title="NewsVine"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database" title="Simpy"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/simpy.png" title="Simpy" alt="Simpy" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://slashdot.org/bookmark.pl?title=Make%20CSV%20File%20from%20Database&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F" title="Slashdot"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database" title="Spurl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database" title="StumbleUpon"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;=Make%20CSV%20File%20from%20Database" title="YahooMyWeb"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://tailrank.com/share/?text=&amp;link_href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database" title="TailRank"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/tailrank.png" title="TailRank" alt="TailRank" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F" title="Technorati"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;t=Make%20CSV%20File%20from%20Database" title="Facebook"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database" title="Google"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database&amp;source=BRADINO+LAMP+Development+Tutorials%2C+Code%2C+Tips+%26amp%3B+Tricks&amp;summary=This%20is%20the%20easiest%20way%20to%20make%20a%20CSV%20file%20from%20a%20database%20query%20and%20output%20it%20to%20the%20user%20for%20download.%20This%20simple%20code%20uses%20the%20PHP5%20fputcsv%20function%20to%20correctly%20format%20an%20array%20of%20values%20into%20a%20line%20in%20a%20csv%20file.%20It%20does%20not%20use%20the%20physical%20fi" title="LinkedIn"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database" title="Live"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;t=Make%20CSV%20File%20from%20Database" title="MySpace"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;title=Make%20CSV%20File%20from%20Database" title="Ping.fm"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/ping.gif" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F&amp;submitHeadline=Make%20CSV%20File%20from%20Database&amp;submitSummary=This%20is%20the%20easiest%20way%20to%20make%20a%20CSV%20file%20from%20a%20database%20query%20and%20output%20it%20to%20the%20user%20for%20download.%20This%20simple%20code%20uses%20the%20PHP5%20fputcsv%20function%20to%20correctly%20format%20an%20array%20of%20values%20into%20a%20line%20in%20a%20csv%20file.%20It%20does%20not%20use%20the%20physical%20fi&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoobuzz.gif" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="mailto:?subject=Make%20CSV%20File%20from%20Database&amp;body=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Fmake-csv-file-from-database%2F" title="E-mail this story to a friend!"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bradino.com/mysql/make-csv-file-from-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Real Escape String</title>
		<link>http://www.bradino.com/mysql/real-escape-string/</link>
		<comments>http://www.bradino.com/mysql/real-escape-string/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 22:26:00 +0000</pubDate>
		<dc:creator>BRADINO</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.bradino.com/mysql/real-escape-string/</guid>
		<description><![CDATA[I always escape MySQL statement parameters from PHP using the function mysql_real_escape_string(), even after I have groomed them. One thing that I always forget is that this function will not work if you have not established a database connection. Without a database connection it returns nothing. If you have error reporting turned on, you will [...]]]></description>
			<content:encoded><![CDATA[<p>I always escape MySQL statement parameters from PHP using the function mysql_real_escape_string(), even after I have groomed them. One thing that I always forget is that this function will not work if you have not established a database connection. Without a database connection it returns nothing. If you have error reporting turned on, you will get a database connection error on the line that you are calling the mysql_real_escape_string() function.</p>
<div class="awmp_tags"><a href="http://www.bradino.com/search/mysql_real_escape_string function/" rel="tag">mysql_real_escape_string function</a> <a href="http://www.bradino.com/search/mysql_real_escape_string/" rel="tag">mysql_real_escape_string</a> <a href="http://www.bradino.com/search/database connection/" rel="tag">database connection</a> <a href="http://www.bradino.com/search/mysql database/" rel="tag">mysql database</a></div>
<div class="sociable">

<ul>
	<li><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String" title="Digg"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://twitter.com/home?status=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F" title="TwitThis"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String" title="del.icio.us"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.netvouz.com/action/submitBookmark?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String&amp;popup=no" title="Netvouz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/netvouz.png" title="Netvouz" alt="Netvouz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String" title="description"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/dzone.png" title="description" alt="description" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String" title="Reddit"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;t=MySQL%20Real%20Escape%20String" title="Furl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;h=MySQL%20Real%20Escape%20String" title="NewsVine"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.simpy.com/simpy/LinkAdd.do?href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String" title="Simpy"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/simpy.png" title="Simpy" alt="Simpy" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://slashdot.org/bookmark.pl?title=MySQL%20Real%20Escape%20String&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F" title="Slashdot"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String" title="Spurl"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String" title="StumbleUpon"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;=MySQL%20Real%20Escape%20String" title="YahooMyWeb"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://tailrank.com/share/?text=&amp;link_href=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String" title="TailRank"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/tailrank.png" title="TailRank" alt="TailRank" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F" title="Technorati"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;t=MySQL%20Real%20Escape%20String" title="Facebook"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String" title="Google"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String&amp;source=BRADINO+LAMP+Development+Tutorials%2C+Code%2C+Tips+%26amp%3B+Tricks&amp;summary=I%20always%20escape%20MySQL%20statement%20parameters%20from%20PHP%20using%20the%20function%20mysql_real_escape_string%28%29%2C%20even%20after%20I%20have%20groomed%20them.%20One%20thing%20that%20I%20always%20forget%20is%20that%20this%20function%20will%20not%20work%20if%20you%20have%20not%20established%20a%20database%20connection.%20W" title="LinkedIn"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String" title="Live"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;t=MySQL%20Real%20Escape%20String" title="MySpace"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;title=MySQL%20Real%20Escape%20String" title="Ping.fm"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/ping.gif" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F&amp;submitHeadline=MySQL%20Real%20Escape%20String&amp;submitSummary=I%20always%20escape%20MySQL%20statement%20parameters%20from%20PHP%20using%20the%20function%20mysql_real_escape_string%28%29%2C%20even%20after%20I%20have%20groomed%20them.%20One%20thing%20that%20I%20always%20forget%20is%20that%20this%20function%20will%20not%20work%20if%20you%20have%20not%20established%20a%20database%20connection.%20W&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/yahoobuzz.gif" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="mailto:?subject=MySQL%20Real%20Escape%20String&amp;body=http%3A%2F%2Fwww.bradino.com%2Fmysql%2Freal-escape-string%2F" title="E-mail this story to a friend!"><img src="http://www.bradino.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bradino.com/mysql/real-escape-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
