<?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>Tim Van Wassenhove &#187; SQL</title>
	<atom:link href="http://www.timvw.be/category/information-technology/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.timvw.be</link>
	<description>The journey of a thousand miles begins with one step.</description>
	<lastBuildDate>Thu, 29 Jul 2010 17:07:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Update from localtime to UTC or any other timezone with Oracle</title>
		<link>http://www.timvw.be/update-from-localtime-to-utc-with-oracle/</link>
		<comments>http://www.timvw.be/update-from-localtime-to-utc-with-oracle/#comments</comments>
		<pubDate>Tue, 17 Jul 2007 20:34:58 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.timvw.be/update-from-localtime-to-utc-with-oracle/</guid>
		<description><![CDATA[Imagine that you have a table with a column of the type DATETIME. You&#8217;ve been storing data as localtime and after a while you need to convert these datetimes to UTC. Here&#8217;s a possible approach: UPDATE events SET start = SYS_EXTRACT_UTC(FROM_TZ(start, 'Europe/Brussels')); You get a more generic variant using the AT TIME ZONE clause: UPDATE [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine that you have a table with a column of the type DATETIME. You&#8217;ve been storing data as localtime and after a while you need to convert these datetimes to UTC. Here&#8217;s a possible approach:</p>
<pre class="brush: sql;">UPDATE events SET start = SYS_EXTRACT_UTC(FROM_TZ(start, 'Europe/Brussels'));</pre>
<p>You get a more generic variant using the AT TIME ZONE clause:</p>
<pre class="brush: sql;">UPDATE events SET start = FROM_TZ(start, 'Europe/Brussels') AT TIME ZONE 'America/Denver';</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/update-from-localtime-to-utc-with-oracle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simulate AutoIncrement</title>
		<link>http://www.timvw.be/simulate-autoincrement/</link>
		<comments>http://www.timvw.be/simulate-autoincrement/#comments</comments>
		<pubDate>Fri, 23 Mar 2007 22:25:01 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.timvw.be/simulate-autoincrement/</guid>
		<description><![CDATA[Earlier today someone asked the following: I&#8217;m trying to move selected data from one table to another. The following works apart from the destination table is not incrementing the ID (I&#8217;m not using auto increment for that field). How can I increase the value of field_1_id for each select > insert? I&#8217;m guessing SQL doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier today someone asked the following:</p>
<blockquote>
<div>
I&#8217;m trying to move selected data from one table to another. The following works apart from the destination table is not incrementing the ID (I&#8217;m not using auto increment for that field).
<br/>
How can I increase the value of field_1_id for each select > insert? I&#8217;m guessing SQL doesn&#8217;t loop through each SELECT match an insert correspondingly?
</div>
</blockquote>

<p>Here is a possible answer: (Don&#8217;t forget to wrap these queries in a transaction if your MySQL Engine supports it)</p>
<pre class="brush: sql;">
-- Some demo tables (and data)
-- CREATE TABLE table1 (id INT(10), name VARCHAR(20), PRIMARY KEY(id));
-- CREATE TABLE table2 (id INT(10), name VARCHAR(20), PRIMARY KEY(id));
-- INSERT INTO table1 VALUES (1, &quot;tim&quot;), (2, &quot;mike&quot;);

SET @id := (SELECT MAX(id) + 1 FROM table2);   
INSERT INTO table2 SELECT @id := @id  + 1, table1.name FROM (SELECT @id) AS id, table1 AS table1; 
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/simulate-autoincrement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a collection as parameter for a stored procedure</title>
		<link>http://www.timvw.be/using-a-collection-as-parameter-for-a-stored-procedure/</link>
		<comments>http://www.timvw.be/using-a-collection-as-parameter-for-a-stored-procedure/#comments</comments>
		<pubDate>Mon, 23 Oct 2006 19:33:00 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.timvw.be/using-a-collection-as-parameter-for-a-stored-procedure/</guid>
		<description><![CDATA[Sometimes you want to select rows where a value is in a specific collection. Here&#8217;s an example that show how you can select all the rows in the TEST table with an id of 1, 2 or 3. First we create an SQL type to contain a list of numbers: CREATE TYPE LIST_NUMBER AS TABLE [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you want to select rows where a value is in a specific collection. Here&#8217;s an example that show how you can select all the rows in the TEST table with an id of 1, 2 or 3. First we create an SQL type to contain a list of numbers:</p>
<pre class="brush: sql;">CREATE TYPE LIST_NUMBER AS TABLE OF NUMBER(10);
/</pre>

<p>Next thing to do is add a custom type and function header to the package specification:</p>
<pre class="brush: sql;">PACKAGE TIMVW.TESTPACKAGE AS
 
TYPE CRSR_REF IS REF CURSOR;
TYPE ARR_IDS IS TABLE OF TEST.TEST_ID%Type INDEX BY BINARY_INTEGER;

PROCEDURE GET_TESTS
(
 P_IDS        IN        ARR_IDS,
 P_CURSOR  OUT     CRSR_REF
);
END;</pre>

<p>And offcourse we have to implement the function in the body:</p>
<pre class="brush: sql;">PROCEDURE GET_TESTS
(
 P_IDS       IN        ARR_IDS,
 P_CURSOR OUT     CRSR_REF
)

AS

V_IDS LIST_NUMBER := LIST_NUMBER();

BEGIN

V_IDS.EXTEND(P_IDS.COUNT);
FOR i IN P_IDS.FIRST .. P_IDS.LAST LOOP
  V_IDS(i) := P_IDS(i);
END LOOP;

OPEN       P_CURSOR FOR
SELECT    
              TEST.TEST_ID,
              TEST.NAME,
              TEST.TYPE_CODE
FROM
              TEST
WHERE
              TEST_ID IN (SELECT * FROM TABLE(V_IDS))
ORDER BY
              TEST.TEST_ID ASC;
END;</pre>

<p>Now that we have done all this we can consume the function from our client code:</p>
<pre class="brush: csharp;">using (OracleConnection conn = new OracleConnection(&quot;User Id=u;password=p;Data Source=ORCL&quot;))
{
 conn.Open();

 OracleCommand command = conn.CreateCommand();
 command.CommandType = CommandType.StoredProcedure;

 command.CommandText = &quot;TIMVW.TESTPACKAGE.GET_TESTS&quot;;
 command.Parameters.Add(&quot;P_IDS&quot;, OracleDbType.Int32, new int[] { 1, 2, 3 }, ParameterDirection.Input);
 command.Parameters[&quot;P_IDS&quot;].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
 command.Parameters.Add(&quot;P_CURSOR&quot;, OracleDbType.RefCursor, ParameterDirection.Output);

 OracleDataReader reader = command.ExecuteReader();
 while (reader.Read())
 {
  Console.WriteLine(&quot;test id: &quot; + reader.GetDecimal(0));
 }

 Console.Write(&quot;{0}Press any key to continue...&quot;, Environment.NewLine);
 Console.ReadKey();
}</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/using-a-collection-as-parameter-for-a-stored-procedure/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Searching made easy</title>
		<link>http://www.timvw.be/searching-made-easy/</link>
		<comments>http://www.timvw.be/searching-made-easy/#comments</comments>
		<pubDate>Sun, 22 Oct 2006 09:09:28 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.timvw.be/searching-made-easy/</guid>
		<description><![CDATA[Very often i have to write queries that return all the rows where one or more columns match a specific value. If i add for every column the condition &#8216;P_COLUMN IS NULL OR COLUMN = P_COLUMN&#8217; to the WHERE clause i only have to write one query. Here&#8217;s an example of such a query: PROCEDURE [...]]]></description>
			<content:encoded><![CDATA[<p>Very often i have to write queries that return all the rows where one or more columns match a specific value. If i add for every column the condition &#8216;P_COLUMN IS NULL OR COLUMN = P_COLUMN&#8217; to the WHERE clause i only have to write one query. Here&#8217;s an example of such a query:</p>

<pre class="brush: sql;">
PROCEDURE FIND_TESTS
(
 P_ID              IN        TEST.ID%Type,
 P_TITLE         IN        TEST.TITLE%Type,
 P_TYPE_CODE IN        TEST.TYPE_CODE%Type,
 P_CURSOR      OUT     CURSOR REF
)

AS

BEGIN

OPEN       
              P_CURSOR FOR
SELECT    
              ID, 
              TITLE,
              TYPE_CODE
FROM       
              TEST
WHERE     
              (P_ID IS NULL OR ID = P_ID)
              AND (P_TITLE IS NULL OR TITLE LIKE P_TITLE) 
              AND (P_TYPE_CODE IS NULL OR TYPE_CODE LIKE P_TYPE_CODE)
ORDER BY 
              ID ASC;
END;
</pre>

<p>A couple of examples how you can use this query:</p>

<pre class="brush: csharp;">
using (OracleConnection conn = new OracleConnection(&quot;User Id=u;password=p;Data Source=ORCL&quot;))
{
 conn.Open();

 OracleCommand command = conn.CreateCommand();
 command.CommandText = &quot;TIMVW.MYPACKAGE.FIND_TESTS&quot;;
 command.CommandType = CommandType.StoredProcedure;

 // select all tests of type_code &quot;book&quot; that have a title that starts with &quot;Myst&quot;
 command.Parameters.Add(&quot;P_ID&quot;, OracleDbType.Int32, 10, DBNull.Value, ParameterDirection.Input);
 command.Parameters.Add(&quot;P_TITLE&quot;, OracleDbType.Varchar2, 20, &quot;Myst%&quot;, ParameterDirection.Input);
 command.Parameters.Add(&quot;P_TYPE_CODE&quot;, OracleDbType.Varchar2, 20, &quot;book&quot;, ParameterDirection.Input);
 command.Parameters.Add(&quot;P_CURSOR&quot;, OracleDbType.RefCursor, ParameterDirection.Output);

 // select the test with id 1
 //command.Parameters.Add(&quot;P_ID&quot;, OracleDbType.Int32, 10, 1, ParameterDirection.Input);
 //command.Parameters.Add(&quot;P_TITLE&quot;, OracleDbType.Varchar2, 20, DBNull.Value, ParameterDirection.Input);
 //command.Parameters.Add(&quot;P_TYPE_CODE&quot;, OracleDbType.Varchar2, 20, DBNull.Value, ParameterDirection.Input);
 //command.Parameters.Add(&quot;P_CURSOR&quot;, OracleDbType.RefCursor, ParameterDirection.Output);

 OracleDataReader reader = command.ExecuteReader();
 while (reader.Read())
 {
  Console.WriteLine(&quot;test id: &quot; + reader.GetDecimal(0));
 }
 
 Console.Write(&quot;{0}Press any key to continue...&quot;, Environment.NewLine);
 Console.ReadKey();
}
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/searching-made-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tweaking Oracle SQL Developer</title>
		<link>http://www.timvw.be/tweaking-oracle-sql-developer/</link>
		<comments>http://www.timvw.be/tweaking-oracle-sql-developer/#comments</comments>
		<pubDate>Sun, 27 Aug 2006 18:10:44 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.timvw.be/tweaking-oracle-sql-developer/</guid>
		<description><![CDATA[A couple of days ago i discovered Oracle SQL Developer, a new and free graphical tool for database development. At first i was impressed by all it&#8217;s features but when i tried to modify a couple of existing stored procedures the application freezed. EricH directed me to the FAQ: Can I suppress Code Insight (and [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago i discovered <a href="http://www.oracle.com/technology/products/database/sql_developer/index.html">Oracle SQL Developer</a>, a new and free graphical tool for database development. At first i was impressed by all it&#8217;s features but when i tried to modify a couple of existing stored procedures the application freezed. <a href="http://forums.oracle.com/forums/profile.jspa?userID=481264">EricH</a> directed me to the <a href="http://www.oracle.com/technology/products/database/sql_developer/files/faqs.html#q3">FAQ: Can I suppress Code Insight (and why would I want to)?</a>. Now that i have added the &#8216;AddVMOption -J-Dsdev.insight=false&#8217; to my sqldeveloper.conf the application runs smooth</p>
<a href="http://www.timvw.be/wp-content/images/oraclesqldeveloper-large.jpg"><img src="http://www.timvw.be/wp-content/images/oraclesqldeveloper-small.jpg" alt="screenshot of oracle sqldeveloper"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/tweaking-oracle-sql-developer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Experimenting with Oracle and PL/SQL</title>
		<link>http://www.timvw.be/experimenting-with-oracle-and-plsql/</link>
		<comments>http://www.timvw.be/experimenting-with-oracle-and-plsql/#comments</comments>
		<pubDate>Mon, 21 Aug 2006 18:12:05 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.timvw.be/experimenting-with-oracle-and-plsql/</guid>
		<description><![CDATA[As i already wrote, last couple of days i&#8217;ve been experimenting with PL/SQL. At work we use Toad for Oracle but since TOADSoft only offers a limited freeware version i decided to write my code with GVim and use SQL*Plus at home. Here are a couple of lines i added to my login.sql file: DEFINE [...]]]></description>
			<content:encoded><![CDATA[<p>As i already wrote, last couple of days i&#8217;ve been experimenting with PL/SQL. At work we use <a href="http://www.toadsoft.com/toad_oracle.htm">Toad for Oracle</a> but since <a href="http://www.toadsoft.com/">TOADSoft</a> only offers a limited freeware version i decided to write my code with <a href="http://www.vim.org">GVim</a> and use <a href="http://orafaq.com/faqplus.htm#WHAT">SQL*Plus</a> at home. Here are a couple of lines i added to my login.sql file:</p>

<pre class="brush: sql;">DEFINE _EDITOR='gvim -c &quot;set filetype=sql&quot;'
SET SERVEROUTPUT ON
SET LINESIZE 120
SET AUTOCOMMIT OFF
ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD';</pre>

<p>In a stored procedure i created and filled an instance of NUMBER_TABLE (CREATE TYPE NUMBER_TABLE AS TABLE OF NUMBER) and my stored procedure tried to select all the rows in that table (SELECT * FROM V_NUMBER_TABLE). Apparently the engine didn&#8217;t know this type @runtime despite the fact that i declared it in my stored procedure (V_NUMBER TABLE NUMBER_TABLE := NUMBER_TABLE();) and the engine compiled the package without errors. I got round that problem as following:</p>

<pre class="brush: sql;">SELECT * FROM (CAST(V_NUMBER_TABLE AS NUMBER_TABLE));</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/experimenting-with-oracle-and-plsql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Select best 3 laptimes for each player</title>
		<link>http://www.timvw.be/select-best-3-laptimes-for-each-player/</link>
		<comments>http://www.timvw.be/select-best-3-laptimes-for-each-player/#comments</comments>
		<pubDate>Fri, 14 Apr 2006 00:45:03 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.timvw.be/select-best-3-laptimes-for-each-player/</guid>
		<description><![CDATA[Imagine that you have a schema where you store all the times a player needed to complete a parcours. A possible schema could be (postgresql): CREATE TABLE laptimes ( lap_id SERIAL NOT NULL, player_id INT NOT NULL, laptime INT NOT NULL, PRIMARY KEY (lap_id) ); INSERT INTO laptimes (player_id, laptime) VALUES (1, 250); INSERT INTO [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine that you have a schema where you store all the times a player needed to complete a parcours. A possible schema could be (<a href="http://www.postgresql.org">postgresql</a>):</p>

<pre class="brush: sql;">
CREATE TABLE laptimes (
 lap_id SERIAL NOT NULL,
 player_id INT NOT NULL,
 laptime INT NOT NULL,
 PRIMARY KEY (lap_id)
);

INSERT INTO laptimes (player_id, laptime) VALUES (1, 250);
INSERT INTO laptimes (player_id, laptime) VALUES (1, 450);
INSERT INTO laptimes (player_id, laptime) VALUES (1, 350);
INSERT INTO laptimes (player_id, laptime) VALUES (1, 300);
INSERT INTO laptimes (player_id, laptime) VALUES (1, 327);

INSERT INTO laptimes (player_id, laptime) VALUES (2, 327);
INSERT INTO laptimes (player_id, laptime) VALUES (2, 249);
INSERT INTO laptimes (player_id, laptime) VALUES (2, 123);
INSERT INTO laptimes (player_id, laptime) VALUES (2, 489);
INSERT INTO laptimes (player_id, laptime) VALUES (2, 158);

INSERT INTO laptimes (player_id, laptime) VALUES (3, 158);
INSERT INTO laptimes (player_id, laptime) VALUES (3, 120);
INSERT INTO laptimes (player_id, laptime) VALUES (3, 190);

INSERT INTO laptimes (player_id, laptime) VALUES (4, 600);
</pre>

<p>Now imagine that you want to display the best 3 results for each player. Here&#8217;s how:</p>

<pre class="brush: sql;">
SELECT *
FROM laptimes AS l1
WHERE lap_id IN (
 SELECT lap_id
 FROM laptimes AS l2
 WHERE l1.player_id = l2.player_id
 ORDER BY laptime ASC
 LIMIT 3
)
ORDER BY player_id ASC, laptime ASC;
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/select-best-3-laptimes-for-each-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple joins explained</title>
		<link>http://www.timvw.be/multiple-joins-explained/</link>
		<comments>http://www.timvw.be/multiple-joins-explained/#comments</comments>
		<pubDate>Fri, 03 Feb 2006 19:52:06 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.timvw.be/multiple-joins-explained/</guid>
		<description><![CDATA[I&#8217;ll try to explain how a join on more than one table works. I&#8217;ve noticed people get confused by it. Assume we have the following tables: newsitems(news_id,post_id) postitems(post_id,user_id,content) users(user_id,name,password) We want to display for each newsitem the content and the author. Our base table would be the newsitems, and then we join using the item_id. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll try to explain how a join on more than one table works. I&#8217;ve noticed people get confused by it. Assume we have the following tables:</p>

<ul>
<li>newsitems(news_id,post_id)</li>
<li>postitems(post_id,user_id,content)</li>
<li>users(user_id,name,password)</li>
</ul>

<p>
We want to display for each newsitem the content and the author. 
</p>

<p>
Our base table would be the newsitems, and then we join using the item_id. Thus the query would be: </p>
<pre class="brush: sql;">
SELECT *
FROM newsitems
INNER JOIN ON postitems USING (post_id)
</pre>

<p>
This returns a &#8220;virtual table&#8221; that has looks like this result(news_id,post_id,user_id,content).
</p>

<p>
Now we still need to get the username, so we use our result table and perform a join on the users table. Thus the query would be:</p>
<pre class="brush: sql;">
SELECT *
FROM result
INNER JOIN users USING (user_id)
</pre>

<p>
If we combine our first two queries, we end up with this:</p>
<pre class="brush: sql;">
SELECT *
FROM newsitems
INNER JOIN postitems USING (post_id)
INNER JOIN users USING (user_id)
</pre>

<p>Conclusion: Look at A*B*C as (A*B)*C to easily understand multiple joins</p>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/multiple-joins-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Select the first 50 words of an article</title>
		<link>http://www.timvw.be/select-the-first-50-words-of-an-article/</link>
		<comments>http://www.timvw.be/select-the-first-50-words-of-an-article/#comments</comments>
		<pubDate>Wed, 18 Jan 2006 00:57:59 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.timvw.be/select-the-first-50-words-of-an-article/</guid>
		<description><![CDATA[I&#8217;m cleaning up my code snippets and i found the following little trick in one of them that i&#8217;ve removed. Assuming that different words are separated by spaces we can use SUBSTRING_INDEX as following: SELECT SUBSTRING_INDEX(body,' ',50) AS dn FROM mytable]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m cleaning up my code snippets and i found the following little trick in one of them that i&#8217;ve removed. Assuming that different words are separated by spaces we can use <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html">SUBSTRING_INDEX</a> as following:</p>
<pre class="brush: sql;">
SELECT SUBSTRING_INDEX(body,' ',50) AS dn FROM mytable
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/select-the-first-50-words-of-an-article/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom ordering with MySQL</title>
		<link>http://www.timvw.be/custom-ordering-with-mysql/</link>
		<comments>http://www.timvw.be/custom-ordering-with-mysql/#comments</comments>
		<pubDate>Wed, 08 Dec 2004 23:10:34 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.timvw.be/custom-ordering-with-mysql/</guid>
		<description><![CDATA[As a follow up to Custom Ordering I discovered the nice Field function in MySQL. after it was mentionned on my favorite PHP Forum by Weirdan. It allows one to order a column on a custom order relation. SELECT * FROM foo ORDER BY FIELD(column, 'Z', 'B', 'C')]]></description>
			<content:encoded><![CDATA[<p>As a follow up to <a href="http://www.timvw.be/custom-ordering">Custom Ordering</a> I discovered the nice <a href="http://dev.mysql.com/doc/mysql/en/String_functions.html">Field</a>  function in <a href="http://www.mysql.com">MySQL.</a> after it was mentionned on my favorite <a href="http://forums.devnetwork.net">PHP Forum</a> by <a href="http://forums.devnetwork.net/profile.php?mode=viewprofile&amp;u=7815">Weirdan</a>. It allows one to order a column on a custom order relation.</p>
<pre class="brush: sql;">
SELECT *
FROM foo
ORDER BY FIELD(column, 'Z', 'B', 'C')
</pre> ]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/custom-ordering-with-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
