On Tue, Dec 10, 2002 at 03:32:13PM +0500, Tariq Murtaza wrote:
> I want to achieve recordset like below (sorting category by Name and 
> including 'Others' at the end),
> I want to do that by single query ;), any idea???
> 
> 
> ID    Category
> ------------------------
> 6     biochemistry
> 62    Commerce
> 95    chemistry
> 2     Engg
> 87    Ecommerce
> 7     math
> 45    physics
> 1     Software Engg   
> 5     Others
> 

Try something like this:

SELECT id, category from mytable order by concat(if(id=5,'B','A'),category);

Only problem is that it won't optimize, so use this on small tables only.


Regards,

Fred.

-- 
Fred van Engen                              XB Networks B.V.
email: [EMAIL PROTECTED]                Televisieweg 2
tel: +31 36 5462400                         1322 AC  Almere
fax: +31 36 5462424                         The Netherlands

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to