<?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>nerdboy.co.uk &#187; MySql</title>
	<atom:link href="http://www.nerdboy.co.uk/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nerdboy.co.uk</link>
	<description>nerdboy blog - web development stuff</description>
	<lastBuildDate>Thu, 03 Jun 2010 10:17:07 +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>MySql and the Art of Sql</title>
		<link>http://www.nerdboy.co.uk/2009/07/mysql-and-the-art-of-sql/</link>
		<comments>http://www.nerdboy.co.uk/2009/07/mysql-and-the-art-of-sql/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 09:48:15 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[MySql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=122</guid>
		<description><![CDATA[I&#8217;ve been reading the The Art of SQL and it makes some very sensible suggestions regarding query performance. Here&#8217;s somewhere I&#8217;ve implemented 1 of the techniques. The task: return records for this month. Usually I&#8217;d write something like select * from results where month(dateadded) = month(now()) and year(dateadded) = year(now()) The problem with this is that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been reading the <a href="http://www.amazon.co.uk/gp/product/0596008945?ie=UTF8&amp;tag=classicwarfil-21&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=0596008945">The Art of SQL</a><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.co.uk/e/ir?t=classicwarfil-21&amp;l=as2&amp;o=2&amp;a=0596008945" border="0" alt="" width="1" height="1" /> and it makes some very sensible suggestions regarding query performance.</p>
<p>Here&#8217;s somewhere I&#8217;ve implemented 1 of the techniques.</p>
<p>The task: return records for this month.</p>
<p>Usually I&#8217;d write something like</p>
<pre class="brush: sql;">select * from results where month(dateadded) = month(now()) and year(dateadded) = year(now())</pre>
<p>The problem with this is that 2 functions (month() and year()) need to be applied to every row to filter the results, this obviously requires overhead.  Also we&#8217;re missing out on any indexes that might be on the dateadded field.</p>
<p>A better approach is to use</p>
<pre class="brush: sql;">select * from results where dateadded &gt;= DATE_FORMAT(now() ,'%Y-%m-01')</pre>
<p>With this approach 1 function is run to find the first day of the month, and if the dateadded field is indexed we&#8217;ll benefit from this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2009/07/mysql-and-the-art-of-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Import csv data into MySql</title>
		<link>http://www.nerdboy.co.uk/2009/05/import-csv-data-into-mysql/</link>
		<comments>http://www.nerdboy.co.uk/2009/05/import-csv-data-into-mysql/#comments</comments>
		<pubDate>Fri, 08 May 2009 19:16:09 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[MySql]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=111</guid>
		<description><![CDATA[Unusually for an asp.net developer, MySql is my database platform of choice &#8211; very quick and less server intensive that certain other database platforms I could mention&#8230; Anyway here&#8217;s how I go about loading csv data into MySql Prepare your data in a program such as excel or open office Save as comma delimied or [...]]]></description>
			<content:encoded><![CDATA[<p>Unusually for an asp.net developer, MySql is my database platform of choice &#8211; very quick and less server intensive that certain other database platforms I could mention&#8230;</p>
<p>Anyway here&#8217;s how I go about loading csv data into MySql</p>
<ul>
<li>Prepare your data in a program such as excel or open office</li>
<li>Save as comma delimied or tab delimited in the file system where mysql stores the data, e.g. if the data is to go in a database called &#8220;test&#8221; then save the csv in C:\Program Files\MySQL\MySQL Server 5.0\data\test</li>
<li>Create a temporary import table whose structure matches the file to import</li>
<li>Make each field a varchar(255) even if the field contains numbers, we can always remove rogue data later &#8211; let&#8217;s just get it into the database first!</li>
<li>Load in the data (note: this is ignoring the first line as it contains the column headers and is set for a tab delimited file)</li>
</ul>
<pre class="brush: sql;">LOAD DATA INFILE 'myimport.txt' INTO TABLE test.tempimporttable

FIELDS TERMINATED BY '\t'

LINES TERMINATED BY '\r\n'

IGNORE 1 LINES</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2009/05/import-csv-data-into-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
