<?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>The How to site &#187; MySQL</title>
	<atom:link href="http://www.bloggpro.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bloggpro.com</link>
	<description>Office tips, CSS, PHP, MySQL scripting and web publishing</description>
	<lastBuildDate>Wed, 28 Apr 2010 00:34:14 +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 fulltext searches</title>
		<link>http://www.bloggpro.com/mysql-fulltext-searches/</link>
		<comments>http://www.bloggpro.com/mysql-fulltext-searches/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 08:03:38 +0000</pubDate>
		<dc:creator>Jesper</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.bloggpro.com/mysql-fulltext-searches/</guid>
		<description><![CDATA[MySQL have a very nifty search function built in, which in many ways are more sophisticated than the WHERE LIKE (&#8217;%'). Using full text search with MATCH (&#8230;) AGAINST (&#8230;) AS relevancy it is also possible to get results ranked by relevancy. Here&#8217;s the quick, dirty way to do it:
1.  First we need to create [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL have a very nifty search function built in, which in many ways are more sophisticated than the <em>WHERE LIKE (&#8217;%')</em>. Using full text search with <em>MATCH (&#8230;) AGAINST (&#8230;) AS relevancy</em> it is also possible to get results ranked by relevancy. Here&#8217;s the quick, dirty way to do it:</p>
<p>1.  First we need to create a full text index for the fields we want to search (note that fields have to be of <em>TEXT</em> or <em>VARCHAR</em> type). This is done by</p>
<blockquote><p><em>ALTER table1 ADD FULLTEXT (&#8217;column1&#8242;,&#8217;column2&#8242;,&#8217;&#8230;&#8217;)</em></p></blockquote>
<p><span id="more-263"></span></p>
<p>2. The search query could then look like this:</p>
<blockquote><p><em>SELECT *, </em><em>MATCH(`column1`,`column2`) AGAINST (&#8217;$phrase&#8217;) AS relevancy</em></p>
<p><em>FROM table 1</em></p>
<p><em>WHERE  </em><em>MATCH(`column1`,`column2`) AGAINST (&#8217;$phrase&#8217;)</em></p></blockquote>
<p>and the result like this:</p>
<blockquote><p> <em>data1   data2  data3  0.9454332 </em></p></blockquote>
<p>where the tailing number would be the score, or relevancy that can be used to rank search results. This is very handy and a lot more user-friendly than the rigid <em>WHERE LIKE</em> construct.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggpro.com/mysql-fulltext-searches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selecting / joining two tables in MySQL &#8211; explained</title>
		<link>http://www.bloggpro.com/selecting-joining-two-tables-in-mysql-explained/</link>
		<comments>http://www.bloggpro.com/selecting-joining-two-tables-in-mysql-explained/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 11:45:57 +0000</pubDate>
		<dc:creator>Jesper</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.bloggpro.com/selecting-joining-two-tables-in-mysql-explained/</guid>
		<description><![CDATA[Trying to create MySQL queries can be a daunting task for the beginner and before understanding the logic it can be really confusing. A common task is to select related data from two tables to generate for example a list of blog posts, where you might want to also display the number of comments for [...]]]></description>
			<content:encoded><![CDATA[<p>Trying to create MySQL queries can be a daunting task for the beginner and before understanding the logic it can be really confusing. A common task is to select related data from two tables to generate for example a list of blog posts, where you might want to also display the number of comments for each post.</p>
<p>This is best done by using a JOIN query. How to construct the query will be explained here, step by step.</p>
<p>First of all, we will put the fields we want to get in the SELECT-statement, like this:<span id="more-260"></span></p>
<blockquote><p><code>SELECT T1.C1, T1.C2, T2.C1, COUNT( T2.C3 ) AS alias1</code></p></blockquote>
<p>T1 denotes table 1 and T2 table 2. C1, C2&#8230;etc denotes columns, or fields. Writing T1.C1 simply means we want to select column 1 in table one. Now the COUNT () AS statement means basically we will count the number of lines in table 2 (which we assume contains the comments) and call them alias1</p>
<blockquote><p><code>FROM T1<br />
LEFT JOIN T2 ON T1.C1 = T2.C1</code></p></blockquote>
<p>Here&#8217;s the trick. Thise statment tells us which tables we are using. T1 is the main table, and then we (left) join table T2 for rows where the condition T1.C1 = T2.C1 is met. Left join is a construct that basically tells MySQL to return also NULL values (fields lacking values) .</p>
<blockquote><p><code>WHERE T1.C2 = '<em>condition</em>'<br />
GROUP BY T1.C1, T1.C2, T2.C1<br />
ORDER BY T1.C3 DESC</code></p></blockquote>
<p>The rest of the statement is straight forward, stating wich results to select from table T1, how the results will be grouped and in what order they should be returned.</p>
<p>Here&#8217;s the full statement:</p>
<blockquote><p><code>SELECT T1.C1, T1.C2, T2.C1, COUNT( T2.C3 ) AS alias1<br />
FROM T1<br />
LEFT JOIN T2 ON T1.C1 = T2.C1<br />
WHERE T1.C2 = '<em>condition</em>'<br />
GROUP BY T1.C1, T1.C2, T2.C1<br />
ORDER BY T1.C3 DESC</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggpro.com/selecting-joining-two-tables-in-mysql-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Select a random row (like user or post) from your MySQL table</title>
		<link>http://www.bloggpro.com/select-a-random-row-like-user-or-post-from-your-mysql-table/</link>
		<comments>http://www.bloggpro.com/select-a-random-row-like-user-or-post-from-your-mysql-table/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 07:05:47 +0000</pubDate>
		<dc:creator>Jesper</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.bloggpro.com/select-a-random-row-like-user-or-post-from-your-mysql-table/</guid>
		<description><![CDATA[I have beein using all kinds of strange constructs to be able to select a random row (often user or post) from table, and then I stubled over this on sitepoint forums:
SELECT * FROM users WHERE age > 20 ORDER BY RAND() LIMIT1
One simple argument to the query! Awsome. Hope it helps you as much [...]]]></description>
			<content:encoded><![CDATA[<p>I have beein using all kinds of strange constructs to be able to select a random row (often user or post) from table, and then I stubled over this on sitepoint forums:</p>
<p><code>SELECT * FROM users WHERE age > 20 ORDER BY RAND() LIMIT1</code></p>
<p>One simple argument to the query! Awsome. Hope it helps you as much as it helped me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggpro.com/select-a-random-row-like-user-or-post-from-your-mysql-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
