<?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>Chris Tate-Davies &#187; order by</title>
	<atom:link href="http://www.christatedavies.co.uk/tag/order-by/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christatedavies.co.uk</link>
	<description>An archive of helpful tit bits of information for development, and probably some stuff that is incomplete, wrong or boring...</description>
	<lastBuildDate>Tue, 31 Jan 2012 11:18:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MySQL &#8211; Order by certain value first</title>
		<link>http://www.christatedavies.co.uk/2010/03/23/mysql-order-by-certain-value-first/</link>
		<comments>http://www.christatedavies.co.uk/2010/03/23/mysql-order-by-certain-value-first/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 21:59:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[order by]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=16</guid>
		<description><![CDATA[Ever wanted to sort a resultset of data, by value, but I wanted a couple of exceptions to appear at the top? SELECT country, population, CASE country WHEN 'United Kingdom' THEN 0 WHEN 'United States' THEN 1 WHEN 'New Zealand" THEN 2 ELSE country END AS countrySort FROM countryList  ORDER BY countrySort ASC; This will [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/03/23/mysql-order-by-certain-value-first/' addthis:title='MySQL &#8211; Order by certain value first ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to sort a resultset of data, by value, but I wanted a couple of exceptions to appear at the top?</p>
<pre>SELECT country, population,
CASE country
WHEN 'United Kingdom' THEN 0
WHEN 'United States' THEN 1
WHEN 'New Zealand" THEN 2
ELSE country
END AS countrySort
FROM countryList 
ORDER BY countrySort ASC;</pre>
<p>This will sort the results by country, but with UK, US, NZ as the top three.</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/03/23/mysql-order-by-certain-value-first/' addthis:title='MySQL &#8211; Order by certain value first ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2010/03/23/mysql-order-by-certain-value-first/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

