MySQL Forums
Forum List  »  Newbie

Re: Categorized column
Posted by: Ramalingam Chelliah
Date: August 23, 2004 04:36AM

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

Options: ReplyQuote


Subject
Written By
Posted
August 21, 2004 02:16AM
Re: Categorized column
August 23, 2004 04:36AM
August 23, 2004 08:11PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.