Hi ,
Check whether the (first) user comment by Jochem Klaver in this manual page is useful for you ...
http://dev.mysql.com/doc/mysql/en/Control_flow_functions.html
-----------------
User Comments
Posted by Jochem Klaver on July 31 2003 3:11am [Delete] [Edit]
If you are searching data and you want to show the result of the search with one column above the other you can use the following (difficult to explain, just read the example):
keyword is "John"
SELECT id, lastname, firstname, IF(lastname LIKE '%John%', 0, 1) as ordervalue FROM customers WHERE lastname LIKE '%John%' OR firstname LIKE '%John%' ORDER BY ordervalue, lastname, firstname;
Now you will first get all the entries where the lastname contains "John" (Johnson) alphabetically listed and then the entries where the firstname contains "John".
----------------
I found this when looking for IF() function and luckily your question came to my mind....
Regards,
Ram.
We Learn the Most When we have to Invent