<?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>Rui Miguel Feio &#187; MySQL</title>
	<atom:link href="http://www.ruifeio.com/category/web-development/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ruifeio.com</link>
	<description>Sharing knowledge with the world</description>
	<lastBuildDate>Sat, 04 Sep 2010 17:29:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Backup and Restore a web site in CPANEL</title>
		<link>http://www.ruifeio.com/2009/08/16/backup-and-restore-a-web-site-in-cpanel/</link>
		<comments>http://www.ruifeio.com/2009/08/16/backup-and-restore-a-web-site-in-cpanel/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 20:18:46 +0000</pubDate>
		<dc:creator>Rui Miguel Feio</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.ruifeio.com/?p=246</guid>
		<description><![CDATA[It&#8217;s a good practice to make backups prior to submit any changes to your site. Time and again people skip the backup to find themselves with problems and not having an easy and quick way to undo their changes. This may not seem a big problem, but if the changes were done to the web [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a good practice to make backups prior to submit any changes to your site.</p>
<p>Time and again people skip the backup to find themselves with problems and not having an easy and quick way to undo their changes. This may not seem a big problem, but if the changes were done to the web site of your business and now the web site is not working probably, this means you&#8217;re losing money!</p>
<p>Backing up a site is easy and even more if your web server uses CPANEL.</p>
<p><strong>Consider the following steps to BACKUP your site:</strong></p>
<ul>
<li>To Backup the files of your site:
<ol>
<li>On <em>CPANEL </em>select option <em>Backups</em></li>
<li>Under <em>Home Directory</em> select option <em>Download a home directory Backup</em></li>
<li>Select <em>Save File</em></li>
</ol>
</li>
<li>To Backup the Databases of your site:
<ol>
<li>On <em>CPANEL </em>select option Backups</li>
<li>Under <span><em>Download a MySQL Database Backup </em>select the Database you wish to Backup</span></li>
<li><span>Select <em>Save File</em></span></li>
<li><span>Repeat Steps 2 and 3 for any other Database you wish to backup</span></li>
</ol>
</li>
</ul>
<p><strong>Consider the following steps to RESTORE your site:</strong></p>
<ul>
<li>To Restore the files of your site:
<ol>
<li>On <em>CPANEL </em>select option <em>Backups</em></li>
<li>Under <em><span>Restore a Home Directory Backup </span></em><span>select <em>Browse </em>and locate the backup you want to restore from<br />
</span></li>
<li>Select <em>Upload</em></li>
</ol>
</li>
<li>To Restore the Databases of your site:
<ol>
<li>On <em>CPANEL </em>select option Backups</li>
<li>Under <em><span>Restore a MySQL Database</span></em><span><em> </em>select <em>Browse </em>and locate the backup you want to restore from.<br />
</span></li>
<li><span>Select <em>Upload</em></span></li>
<li><span>Repeat Steps 2 and 3 for any other Database you wish to restore</span></li>
</ol>
</li>
</ul>
<div class="fullcircle-social-links" style="display: block;"></div><div style="clear: both;"></div>
<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="mailto:?subject=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL&amp;body=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F" title="email"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;t=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL" title="Facebook"><img src="http://www.ruifeio.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://twitter.com/home?status=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL%20-%20http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F" title="Twitter"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;t=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL" title="MySpace"><img src="http://www.ruifeio.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://delicious.com/post?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;title=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL&amp;notes=It%27s%20a%20good%20practice%20to%20make%20backups%20prior%20to%20submit%20any%20changes%20to%20your%20site.%0D%0A%0D%0ATime%20and%20again%20people%20skip%20the%20backup%20to%20find%20themselves%20with%20problems%20and%20not%20having%20an%20easy%20and%20quick%20way%20to%20undo%20their%20changes.%20This%20may%20not%20seem%20a%20big%20problem%2C%20but%20" title="del.icio.us"><img src="http://www.ruifeio.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.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;title=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL&amp;source=Rui+Miguel+Feio+Sharing+knowledge+with+the+world&amp;summary=It%27s%20a%20good%20practice%20to%20make%20backups%20prior%20to%20submit%20any%20changes%20to%20your%20site.%0D%0A%0D%0ATime%20and%20again%20people%20skip%20the%20backup%20to%20find%20themselves%20with%20problems%20and%20not%20having%20an%20easy%20and%20quick%20way%20to%20undo%20their%20changes.%20This%20may%20not%20seem%20a%20big%20problem%2C%20but%20" title="LinkedIn"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;title=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL&amp;bodytext=It%27s%20a%20good%20practice%20to%20make%20backups%20prior%20to%20submit%20any%20changes%20to%20your%20site.%0D%0A%0D%0ATime%20and%20again%20people%20skip%20the%20backup%20to%20find%20themselves%20with%20problems%20and%20not%20having%20an%20easy%20and%20quick%20way%20to%20undo%20their%20changes.%20This%20may%20not%20seem%20a%20big%20problem%2C%20but%20" title="Digg"><img src="http://www.ruifeio.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://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;title=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL" title="StumbleUpon"><img src="http://www.ruifeio.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://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;title=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL&amp;annotation=It%27s%20a%20good%20practice%20to%20make%20backups%20prior%20to%20submit%20any%20changes%20to%20your%20site.%0D%0A%0D%0ATime%20and%20again%20people%20skip%20the%20backup%20to%20find%20themselves%20with%20problems%20and%20not%20having%20an%20easy%20and%20quick%20way%20to%20undo%20their%20changes.%20This%20may%20not%20seem%20a%20big%20problem%2C%20but%20" title="Google Bookmarks"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;submitHeadline=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL&amp;submitSummary=It%27s%20a%20good%20practice%20to%20make%20backups%20prior%20to%20submit%20any%20changes%20to%20your%20site.%0D%0A%0D%0ATime%20and%20again%20people%20skip%20the%20backup%20to%20find%20themselves%20with%20problems%20and%20not%20having%20an%20easy%20and%20quick%20way%20to%20undo%20their%20changes.%20This%20may%20not%20seem%20a%20big%20problem%2C%20but%20&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F" title="IndianPad"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ruifeio.com/2009/08/16/backup-and-restore-a-web-site-in-cpanel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to select the First row from a MySQL table</title>
		<link>http://www.ruifeio.com/2009/07/06/how-to-select-the-first-row-from-a-mysql-table/</link>
		<comments>http://www.ruifeio.com/2009/07/06/how-to-select-the-first-row-from-a-mysql-table/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 17:30:07 +0000</pubDate>
		<dc:creator>Rui Miguel Feio</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.ruifeio.com/?p=178</guid>
		<description><![CDATA[You can use the following command to get the first row from a MySQL table: SELECT * FROM table LIMIT 1 Explanation: table - table name By limiting the returns to 1 (LIMIT 1) we get the first row from the table. Example: SELECT * FROM tusers LIMIT 1]]></description>
			<content:encoded><![CDATA[<p>You can use the following command to get the first row from a MySQL table:</p>
<p>SELECT * FROM <em>table </em>LIMIT 1</p>
<p><strong>Explanation:</strong></p>
<p><em>table </em>- table name</p>
<p><em> </em></p>
<p>By limiting the returns to 1 (LIMIT 1) we get the first row from the table.</p>
<p><strong>Example:</strong></p>
<p>SELECT * FROM <em>tusers </em>LIMIT 1</p>
<div class="fullcircle-social-links" style="display: block;"></div><div style="clear: both;"></div>
<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="mailto:?subject=How%20to%20select%20the%20First%20row%20from%20a%20MySQL%20table&amp;body=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-first-row-from-a-mysql-table%2F" title="email"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-first-row-from-a-mysql-table%2F&amp;t=How%20to%20select%20the%20First%20row%20from%20a%20MySQL%20table" title="Facebook"><img src="http://www.ruifeio.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://twitter.com/home?status=How%20to%20select%20the%20First%20row%20from%20a%20MySQL%20table%20-%20http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-first-row-from-a-mysql-table%2F" title="Twitter"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-first-row-from-a-mysql-table%2F&amp;t=How%20to%20select%20the%20First%20row%20from%20a%20MySQL%20table" title="MySpace"><img src="http://www.ruifeio.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://delicious.com/post?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-first-row-from-a-mysql-table%2F&amp;title=How%20to%20select%20the%20First%20row%20from%20a%20MySQL%20table&amp;notes=You%20can%20use%20the%20following%20command%20to%20get%20the%20first%20row%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20LIMIT%201%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0A%20%0D%0A%0D%0ABy%20limiting%20the%20returns%20to%201%20%28LIMIT%201%29%20we%20get%20the%20first%20row%20from%20the%20table.%0D%0A%0D%0AExample%3A%0D%0A%0D%0ASELECT%20" title="del.icio.us"><img src="http://www.ruifeio.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.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-first-row-from-a-mysql-table%2F&amp;title=How%20to%20select%20the%20First%20row%20from%20a%20MySQL%20table&amp;source=Rui+Miguel+Feio+Sharing+knowledge+with+the+world&amp;summary=You%20can%20use%20the%20following%20command%20to%20get%20the%20first%20row%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20LIMIT%201%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0A%20%0D%0A%0D%0ABy%20limiting%20the%20returns%20to%201%20%28LIMIT%201%29%20we%20get%20the%20first%20row%20from%20the%20table.%0D%0A%0D%0AExample%3A%0D%0A%0D%0ASELECT%20" title="LinkedIn"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-first-row-from-a-mysql-table%2F&amp;title=How%20to%20select%20the%20First%20row%20from%20a%20MySQL%20table&amp;bodytext=You%20can%20use%20the%20following%20command%20to%20get%20the%20first%20row%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20LIMIT%201%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0A%20%0D%0A%0D%0ABy%20limiting%20the%20returns%20to%201%20%28LIMIT%201%29%20we%20get%20the%20first%20row%20from%20the%20table.%0D%0A%0D%0AExample%3A%0D%0A%0D%0ASELECT%20" title="Digg"><img src="http://www.ruifeio.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://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-first-row-from-a-mysql-table%2F&amp;title=How%20to%20select%20the%20First%20row%20from%20a%20MySQL%20table" title="StumbleUpon"><img src="http://www.ruifeio.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://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-first-row-from-a-mysql-table%2F&amp;title=How%20to%20select%20the%20First%20row%20from%20a%20MySQL%20table&amp;annotation=You%20can%20use%20the%20following%20command%20to%20get%20the%20first%20row%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20LIMIT%201%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0A%20%0D%0A%0D%0ABy%20limiting%20the%20returns%20to%201%20%28LIMIT%201%29%20we%20get%20the%20first%20row%20from%20the%20table.%0D%0A%0D%0AExample%3A%0D%0A%0D%0ASELECT%20" title="Google Bookmarks"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-first-row-from-a-mysql-table%2F&amp;submitHeadline=How%20to%20select%20the%20First%20row%20from%20a%20MySQL%20table&amp;submitSummary=You%20can%20use%20the%20following%20command%20to%20get%20the%20first%20row%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20LIMIT%201%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0A%20%0D%0A%0D%0ABy%20limiting%20the%20returns%20to%201%20%28LIMIT%201%29%20we%20get%20the%20first%20row%20from%20the%20table.%0D%0A%0D%0AExample%3A%0D%0A%0D%0ASELECT%20&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-first-row-from-a-mysql-table%2F" title="IndianPad"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ruifeio.com/2009/07/06/how-to-select-the-first-row-from-a-mysql-table/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to select the Last row from a MySQL table</title>
		<link>http://www.ruifeio.com/2009/07/06/how-to-select-the-last-row-from-a-mysql-table/</link>
		<comments>http://www.ruifeio.com/2009/07/06/how-to-select-the-last-row-from-a-mysql-table/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 17:24:44 +0000</pubDate>
		<dc:creator>Rui Miguel Feio</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.ruifeio.com/?p=174</guid>
		<description><![CDATA[You can use the following command to get the last row from a MySQL table: SELECT * FROM table ORDER BY field DESC LIMIT 1 Explanation: table - table name field - table field This command orders the table by DESCENDING order and limits the number of rows returned to 1. Since DESCENDING reverses the [...]]]></description>
			<content:encoded><![CDATA[<p>You can use the following command to get the last row from a MySQL table:</p>
<p>SELECT * FROM <em>table </em>ORDER BY <em>field </em>DESC LIMIT 1</p>
<p><strong>Explanation:</strong></p>
<p><em>table </em>- table name</p>
<p><em>field </em>- table field</p>
<p>This command orders the table by DESCENDING order and limits the number of rows returned to 1. Since DESCENDING reverses the normal table order, we get its last row.</p>
<p><strong>Example:</strong></p>
<p>SELECT * FROM <em>tusers </em>ORDER BY <em>user_id</em> DESC LIMIT 1</p>
<div class="fullcircle-social-links" style="display: block;"></div><div style="clear: both;"></div>
<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="mailto:?subject=How%20to%20select%20the%20Last%20row%20from%20a%20MySQL%20table&amp;body=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-last-row-from-a-mysql-table%2F" title="email"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-last-row-from-a-mysql-table%2F&amp;t=How%20to%20select%20the%20Last%20row%20from%20a%20MySQL%20table" title="Facebook"><img src="http://www.ruifeio.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://twitter.com/home?status=How%20to%20select%20the%20Last%20row%20from%20a%20MySQL%20table%20-%20http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-last-row-from-a-mysql-table%2F" title="Twitter"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-last-row-from-a-mysql-table%2F&amp;t=How%20to%20select%20the%20Last%20row%20from%20a%20MySQL%20table" title="MySpace"><img src="http://www.ruifeio.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://delicious.com/post?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-last-row-from-a-mysql-table%2F&amp;title=How%20to%20select%20the%20Last%20row%20from%20a%20MySQL%20table&amp;notes=You%20can%20use%20the%20following%20command%20to%20get%20the%20last%20row%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20ORDER%20BY%20field%20DESC%20LIMIT%201%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0Afield%20-%20table%20field%0D%0A%0D%0AThis%20command%20orders%20the%20table%20by%20DESCENDING%20order%20and%20limits%20" title="del.icio.us"><img src="http://www.ruifeio.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.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-last-row-from-a-mysql-table%2F&amp;title=How%20to%20select%20the%20Last%20row%20from%20a%20MySQL%20table&amp;source=Rui+Miguel+Feio+Sharing+knowledge+with+the+world&amp;summary=You%20can%20use%20the%20following%20command%20to%20get%20the%20last%20row%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20ORDER%20BY%20field%20DESC%20LIMIT%201%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0Afield%20-%20table%20field%0D%0A%0D%0AThis%20command%20orders%20the%20table%20by%20DESCENDING%20order%20and%20limits%20" title="LinkedIn"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-last-row-from-a-mysql-table%2F&amp;title=How%20to%20select%20the%20Last%20row%20from%20a%20MySQL%20table&amp;bodytext=You%20can%20use%20the%20following%20command%20to%20get%20the%20last%20row%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20ORDER%20BY%20field%20DESC%20LIMIT%201%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0Afield%20-%20table%20field%0D%0A%0D%0AThis%20command%20orders%20the%20table%20by%20DESCENDING%20order%20and%20limits%20" title="Digg"><img src="http://www.ruifeio.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://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-last-row-from-a-mysql-table%2F&amp;title=How%20to%20select%20the%20Last%20row%20from%20a%20MySQL%20table" title="StumbleUpon"><img src="http://www.ruifeio.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://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-last-row-from-a-mysql-table%2F&amp;title=How%20to%20select%20the%20Last%20row%20from%20a%20MySQL%20table&amp;annotation=You%20can%20use%20the%20following%20command%20to%20get%20the%20last%20row%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20ORDER%20BY%20field%20DESC%20LIMIT%201%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0Afield%20-%20table%20field%0D%0A%0D%0AThis%20command%20orders%20the%20table%20by%20DESCENDING%20order%20and%20limits%20" title="Google Bookmarks"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-last-row-from-a-mysql-table%2F&amp;submitHeadline=How%20to%20select%20the%20Last%20row%20from%20a%20MySQL%20table&amp;submitSummary=You%20can%20use%20the%20following%20command%20to%20get%20the%20last%20row%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20ORDER%20BY%20field%20DESC%20LIMIT%201%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0Afield%20-%20table%20field%0D%0A%0D%0AThis%20command%20orders%20the%20table%20by%20DESCENDING%20order%20and%20limits%20&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fhow-to-select-the-last-row-from-a-mysql-table%2F" title="IndianPad"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ruifeio.com/2009/07/06/how-to-select-the-last-row-from-a-mysql-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Select random rows from a MySQL table</title>
		<link>http://www.ruifeio.com/2009/07/06/select-random-rows-from-mysql-table/</link>
		<comments>http://www.ruifeio.com/2009/07/06/select-random-rows-from-mysql-table/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 17:14:41 +0000</pubDate>
		<dc:creator>Rui Miguel Feio</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.ruifeio.com/?p=168</guid>
		<description><![CDATA[If you ever come across the need of randomly select rows from a MySQL table: SELECT * FROM table WHERE field1 = value ORDER BY RAND() LIMIT x Explanation: table - table name field1 - table field value - value you want field1 to be x &#8211; number of rows to return Example: SELECT * [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever come across the need of randomly select rows from a MySQL table:</p>
<p>SELECT * FROM <em>table </em>WHERE <em>field1 </em>= <em>value </em>ORDER BY RAND() LIMIT <em>x</em></p>
<p><strong>Explanation:</strong></p>
<p><em>table </em>- table name</p>
<p><em>field1 </em>- table field</p>
<p><em>value </em>- value you want field1 to be</p>
<p><em>x</em> &#8211; number of rows to return</p>
<p><strong>Example:</strong></p>
<p>SELECT * FROM <em>tusers </em>WHERE <em>active_user </em>= &#8216;<em>Yes</em>&#8216; ORDER BY RAND() LIMIT <em>10</em></p>
<p>This command returns 10 random rows of active users from table tusers.</p>
<div class="fullcircle-social-links" style="display: block;"></div><div style="clear: both;"></div>
<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="mailto:?subject=Select%20random%20rows%20from%20a%20MySQL%20table&amp;body=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fselect-random-rows-from-mysql-table%2F" title="email"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fselect-random-rows-from-mysql-table%2F&amp;t=Select%20random%20rows%20from%20a%20MySQL%20table" title="Facebook"><img src="http://www.ruifeio.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://twitter.com/home?status=Select%20random%20rows%20from%20a%20MySQL%20table%20-%20http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fselect-random-rows-from-mysql-table%2F" title="Twitter"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fselect-random-rows-from-mysql-table%2F&amp;t=Select%20random%20rows%20from%20a%20MySQL%20table" title="MySpace"><img src="http://www.ruifeio.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://delicious.com/post?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fselect-random-rows-from-mysql-table%2F&amp;title=Select%20random%20rows%20from%20a%20MySQL%20table&amp;notes=If%20you%20ever%20come%20across%20the%20need%20of%20randomly%20select%20rows%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20WHERE%20field1%20%3D%20value%20ORDER%20BY%20RAND%28%29%20LIMIT%20x%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0Afield1%20-%20table%20field%0D%0A%0D%0Avalue%20-%20value%20you%20want%20field1%20to%20be%0D%0A%0D%0Ax" title="del.icio.us"><img src="http://www.ruifeio.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.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fselect-random-rows-from-mysql-table%2F&amp;title=Select%20random%20rows%20from%20a%20MySQL%20table&amp;source=Rui+Miguel+Feio+Sharing+knowledge+with+the+world&amp;summary=If%20you%20ever%20come%20across%20the%20need%20of%20randomly%20select%20rows%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20WHERE%20field1%20%3D%20value%20ORDER%20BY%20RAND%28%29%20LIMIT%20x%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0Afield1%20-%20table%20field%0D%0A%0D%0Avalue%20-%20value%20you%20want%20field1%20to%20be%0D%0A%0D%0Ax" title="LinkedIn"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fselect-random-rows-from-mysql-table%2F&amp;title=Select%20random%20rows%20from%20a%20MySQL%20table&amp;bodytext=If%20you%20ever%20come%20across%20the%20need%20of%20randomly%20select%20rows%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20WHERE%20field1%20%3D%20value%20ORDER%20BY%20RAND%28%29%20LIMIT%20x%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0Afield1%20-%20table%20field%0D%0A%0D%0Avalue%20-%20value%20you%20want%20field1%20to%20be%0D%0A%0D%0Ax" title="Digg"><img src="http://www.ruifeio.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://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fselect-random-rows-from-mysql-table%2F&amp;title=Select%20random%20rows%20from%20a%20MySQL%20table" title="StumbleUpon"><img src="http://www.ruifeio.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://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fselect-random-rows-from-mysql-table%2F&amp;title=Select%20random%20rows%20from%20a%20MySQL%20table&amp;annotation=If%20you%20ever%20come%20across%20the%20need%20of%20randomly%20select%20rows%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20WHERE%20field1%20%3D%20value%20ORDER%20BY%20RAND%28%29%20LIMIT%20x%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0Afield1%20-%20table%20field%0D%0A%0D%0Avalue%20-%20value%20you%20want%20field1%20to%20be%0D%0A%0D%0Ax" title="Google Bookmarks"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fselect-random-rows-from-mysql-table%2F&amp;submitHeadline=Select%20random%20rows%20from%20a%20MySQL%20table&amp;submitSummary=If%20you%20ever%20come%20across%20the%20need%20of%20randomly%20select%20rows%20from%20a%20MySQL%20table%3A%0D%0A%0D%0ASELECT%20%2A%20FROM%20table%20WHERE%20field1%20%3D%20value%20ORDER%20BY%20RAND%28%29%20LIMIT%20x%0D%0A%0D%0AExplanation%3A%0D%0A%0D%0Atable%20-%20table%20name%0D%0A%0D%0Afield1%20-%20table%20field%0D%0A%0D%0Avalue%20-%20value%20you%20want%20field1%20to%20be%0D%0A%0D%0Ax&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F06%2Fselect-random-rows-from-mysql-table%2F" title="IndianPad"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ruifeio.com/2009/07/06/select-random-rows-from-mysql-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to identify a MySQL query problem</title>
		<link>http://www.ruifeio.com/2009/07/01/how-to-identify-the-mysql-query-problem/</link>
		<comments>http://www.ruifeio.com/2009/07/01/how-to-identify-the-mysql-query-problem/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 20:38:24 +0000</pubDate>
		<dc:creator>Rui Miguel Feio</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ruifeio.com/?p=65</guid>
		<description><![CDATA[Sometimes you happen to have a problem with one of your MySQL queries and you simply can&#8217;t seem to understand why. Well, one thing that helps is to use the mysql_error() function. This function returns the message of the MySQL error you&#8217;re getting. Example: $action = &#8220;INSERT INTO table (name, address, dob) VALUES (&#8216;$name&#8217;, &#8216;$address&#8217;, [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you happen to have a problem with one of your MySQL queries and you simply can&#8217;t seem to understand why.</p>
<p>Well, one thing that helps is to use the <em>mysql_error()</em> function.</p>
<p>This function returns the message of the MySQL error you&#8217;re getting.</p>
<p><strong>Example:</strong></p>
<p>$action = &#8220;INSERT INTO table (name, address, dob) VALUES (&#8216;$name&#8217;, &#8216;$address&#8217;, &#8216;$dob&#8217;)&#8221;;<br />
$query = mysql_query($action) or <strong>die(mysql_error())</strong>;</p>
<p>If we happen to get a problem with our MySQL error the script execution will stop (by using the <em>die()</em> function) and the MySQL error message will be returned (by using the <em>mysql_error()</em> function).</p>
<div class="fullcircle-social-links" style="display: block;"></div><div style="clear: both;"></div>
<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="mailto:?subject=How%20to%20identify%20a%20MySQL%20query%20problem&amp;body=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F" title="email"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;t=How%20to%20identify%20a%20MySQL%20query%20problem" title="Facebook"><img src="http://www.ruifeio.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://twitter.com/home?status=How%20to%20identify%20a%20MySQL%20query%20problem%20-%20http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F" title="Twitter"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;t=How%20to%20identify%20a%20MySQL%20query%20problem" title="MySpace"><img src="http://www.ruifeio.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://delicious.com/post?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;title=How%20to%20identify%20a%20MySQL%20query%20problem&amp;notes=Sometimes%20you%20happen%20to%20have%20a%20problem%20with%20one%20of%20your%20MySQL%20queries%20and%20you%20simply%20can%27t%20seem%20to%20understand%20why.%0D%0A%0D%0AWell%2C%20one%20thing%20that%20helps%20is%20to%20use%20the%20mysql_error%28%29%20function.%0D%0A%0D%0AThis%20function%20returns%20the%20message%20of%20the%20MySQL%20error%20you%27re%20gett" title="del.icio.us"><img src="http://www.ruifeio.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.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;title=How%20to%20identify%20a%20MySQL%20query%20problem&amp;source=Rui+Miguel+Feio+Sharing+knowledge+with+the+world&amp;summary=Sometimes%20you%20happen%20to%20have%20a%20problem%20with%20one%20of%20your%20MySQL%20queries%20and%20you%20simply%20can%27t%20seem%20to%20understand%20why.%0D%0A%0D%0AWell%2C%20one%20thing%20that%20helps%20is%20to%20use%20the%20mysql_error%28%29%20function.%0D%0A%0D%0AThis%20function%20returns%20the%20message%20of%20the%20MySQL%20error%20you%27re%20gett" title="LinkedIn"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;title=How%20to%20identify%20a%20MySQL%20query%20problem&amp;bodytext=Sometimes%20you%20happen%20to%20have%20a%20problem%20with%20one%20of%20your%20MySQL%20queries%20and%20you%20simply%20can%27t%20seem%20to%20understand%20why.%0D%0A%0D%0AWell%2C%20one%20thing%20that%20helps%20is%20to%20use%20the%20mysql_error%28%29%20function.%0D%0A%0D%0AThis%20function%20returns%20the%20message%20of%20the%20MySQL%20error%20you%27re%20gett" title="Digg"><img src="http://www.ruifeio.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://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;title=How%20to%20identify%20a%20MySQL%20query%20problem" title="StumbleUpon"><img src="http://www.ruifeio.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://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;title=How%20to%20identify%20a%20MySQL%20query%20problem&amp;annotation=Sometimes%20you%20happen%20to%20have%20a%20problem%20with%20one%20of%20your%20MySQL%20queries%20and%20you%20simply%20can%27t%20seem%20to%20understand%20why.%0D%0A%0D%0AWell%2C%20one%20thing%20that%20helps%20is%20to%20use%20the%20mysql_error%28%29%20function.%0D%0A%0D%0AThis%20function%20returns%20the%20message%20of%20the%20MySQL%20error%20you%27re%20gett" title="Google Bookmarks"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;submitHeadline=How%20to%20identify%20a%20MySQL%20query%20problem&amp;submitSummary=Sometimes%20you%20happen%20to%20have%20a%20problem%20with%20one%20of%20your%20MySQL%20queries%20and%20you%20simply%20can%27t%20seem%20to%20understand%20why.%0D%0A%0D%0AWell%2C%20one%20thing%20that%20helps%20is%20to%20use%20the%20mysql_error%28%29%20function.%0D%0A%0D%0AThis%20function%20returns%20the%20message%20of%20the%20MySQL%20error%20you%27re%20gett&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F" title="IndianPad"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ruifeio.com/2009/07/01/how-to-identify-the-mysql-query-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Work with records older then x days</title>
		<link>http://www.ruifeio.com/2009/06/29/delete-records-older-then-x-days/</link>
		<comments>http://www.ruifeio.com/2009/06/29/delete-records-older-then-x-days/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 20:27:14 +0000</pubDate>
		<dc:creator>Rui Miguel Feio</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.ruifeio.com/?p=11</guid>
		<description><![CDATA[For the sake of this example, let&#8217;s assume that: we want to work with records older then 60 days the table name is &#8216;table&#8217; (how original!) the table field with dates is called date_field DELETE FROM table WHERE date_field &#60; DATE_SUB(CURDATE(),INTERVAL 60 DAY) This MySQL command deletes all table rows whose date is older then [...]]]></description>
			<content:encoded><![CDATA[<p>For the sake of this example, let&#8217;s assume that:</p>
<ol>
<li>we want to work with records older then 60 days</li>
<li>the table name is &#8216;table&#8217; (how original!)</li>
<li>the table field with dates is called date_field <img src='http://www.ruifeio.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
</ol>
<hr />
<p><strong>DELETE FROM </strong>table<strong> WHERE </strong>date_field<strong> &lt; DATE_SUB(CURDATE(),INTERVAL </strong>60<strong> DAY)</strong></p>
<p>This MySQL command deletes all table rows whose date is older then 60 days from current date &#8211; CURDATE() -.</p>
<hr />
<p><strong>SELECT </strong>something<strong> FROM </strong>table <strong>WHERE </strong>date_field<strong>&lt; DATE_SUB(CURDATE(),INTERVAL </strong>60<strong> DAY)</strong></p>
<p>This MySQL command selects all table rows whose date is older then 60 days from current date &#8211; CURDATE() -.</p>
<hr />
<p><strong>Explanation:</strong></p>
<p>DATE_SUB(<em>date</em>,INTERVAL <em>expr</em> <em>unit</em>) -&gt; Subtracts two dates</p>
<p>CURDATE() -&gt; Returns the current date</p>
<p><em>unit</em> can be:</p>
<ul>
<li>MICROSECOND</li>
<li>SECOND</li>
<li>MINUTE</li>
<li>HOUR</li>
<li>DAY</li>
<li>WEEK</li>
<li>MONTH</li>
<li>QUARTER</li>
<li>YEAR</li>
<li>SECOND_MICROSECOND</li>
<li>MINUTE_MICROSECOND</li>
<li>MINUTE_SECOND</li>
<li>HOUR_MICROSECOND</li>
<li>HOUR_SECOND</li>
<li>HOUR_MINUTE</li>
<li>DAY_MICROSECOND</li>
<li>DAY_SECOND</li>
<li>DAY_MINUTE</li>
<li>DAY_HOUR</li>
<li>YEAR_MONTH</li>
</ul>
<div class="fullcircle-social-links" style="display: block;"></div><div style="clear: both;"></div>
<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="mailto:?subject=Work%20with%20records%20older%20then%20x%20days&amp;body=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F29%2Fdelete-records-older-then-x-days%2F" title="email"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F29%2Fdelete-records-older-then-x-days%2F&amp;t=Work%20with%20records%20older%20then%20x%20days" title="Facebook"><img src="http://www.ruifeio.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://twitter.com/home?status=Work%20with%20records%20older%20then%20x%20days%20-%20http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F29%2Fdelete-records-older-then-x-days%2F" title="Twitter"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F29%2Fdelete-records-older-then-x-days%2F&amp;t=Work%20with%20records%20older%20then%20x%20days" title="MySpace"><img src="http://www.ruifeio.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://delicious.com/post?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F29%2Fdelete-records-older-then-x-days%2F&amp;title=Work%20with%20records%20older%20then%20x%20days&amp;notes=For%20the%20sake%20of%20this%20example%2C%20let%27s%20assume%20that%3A%0D%0A%0D%0A%09we%20want%20to%20work%20with%20records%20older%20then%2060%20days%0D%0A%09the%20table%20name%20is%20%27table%27%20%28how%20original%21%29%0D%0A%09the%20table%20field%20with%20dates%20is%20called%20date_field%20%3A-%29%0D%0A%0D%0A%0D%0ADELETE%20FROM%20table%20WHERE%20date_field%20%26lt%3B%20DATE_S" title="del.icio.us"><img src="http://www.ruifeio.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.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F29%2Fdelete-records-older-then-x-days%2F&amp;title=Work%20with%20records%20older%20then%20x%20days&amp;source=Rui+Miguel+Feio+Sharing+knowledge+with+the+world&amp;summary=For%20the%20sake%20of%20this%20example%2C%20let%27s%20assume%20that%3A%0D%0A%0D%0A%09we%20want%20to%20work%20with%20records%20older%20then%2060%20days%0D%0A%09the%20table%20name%20is%20%27table%27%20%28how%20original%21%29%0D%0A%09the%20table%20field%20with%20dates%20is%20called%20date_field%20%3A-%29%0D%0A%0D%0A%0D%0ADELETE%20FROM%20table%20WHERE%20date_field%20%26lt%3B%20DATE_S" title="LinkedIn"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F29%2Fdelete-records-older-then-x-days%2F&amp;title=Work%20with%20records%20older%20then%20x%20days&amp;bodytext=For%20the%20sake%20of%20this%20example%2C%20let%27s%20assume%20that%3A%0D%0A%0D%0A%09we%20want%20to%20work%20with%20records%20older%20then%2060%20days%0D%0A%09the%20table%20name%20is%20%27table%27%20%28how%20original%21%29%0D%0A%09the%20table%20field%20with%20dates%20is%20called%20date_field%20%3A-%29%0D%0A%0D%0A%0D%0ADELETE%20FROM%20table%20WHERE%20date_field%20%26lt%3B%20DATE_S" title="Digg"><img src="http://www.ruifeio.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://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F29%2Fdelete-records-older-then-x-days%2F&amp;title=Work%20with%20records%20older%20then%20x%20days" title="StumbleUpon"><img src="http://www.ruifeio.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://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F29%2Fdelete-records-older-then-x-days%2F&amp;title=Work%20with%20records%20older%20then%20x%20days&amp;annotation=For%20the%20sake%20of%20this%20example%2C%20let%27s%20assume%20that%3A%0D%0A%0D%0A%09we%20want%20to%20work%20with%20records%20older%20then%2060%20days%0D%0A%09the%20table%20name%20is%20%27table%27%20%28how%20original%21%29%0D%0A%09the%20table%20field%20with%20dates%20is%20called%20date_field%20%3A-%29%0D%0A%0D%0A%0D%0ADELETE%20FROM%20table%20WHERE%20date_field%20%26lt%3B%20DATE_S" title="Google Bookmarks"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F29%2Fdelete-records-older-then-x-days%2F&amp;submitHeadline=Work%20with%20records%20older%20then%20x%20days&amp;submitSummary=For%20the%20sake%20of%20this%20example%2C%20let%27s%20assume%20that%3A%0D%0A%0D%0A%09we%20want%20to%20work%20with%20records%20older%20then%2060%20days%0D%0A%09the%20table%20name%20is%20%27table%27%20%28how%20original%21%29%0D%0A%09the%20table%20field%20with%20dates%20is%20called%20date_field%20%3A-%29%0D%0A%0D%0A%0D%0ADELETE%20FROM%20table%20WHERE%20date_field%20%26lt%3B%20DATE_S&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F29%2Fdelete-records-older-then-x-days%2F" title="IndianPad"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ruifeio.com/2009/06/29/delete-records-older-then-x-days/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
