"Jeff Shipman - SysProg" <[EMAIL PROTECTED]> wrote:
> I would like to do something similar to an ORDER BY
> in one of my select statements, but I'mt not sure
> how to do something as complicated as this:
>
> I have two columns, category and subcategory, that
> I am retrieving. I would like category and subcategory
> to be sorted alphabetically. This is easy with an
> 'ORDER BY 1 2', but I would like categories that
> are named 'other' to be put off until the end. So,
> I'd get something like this:
>
> abcd
> ghikj
> zzzzz
> other
>
> Is there a way to do this type of query? Thanks in
> advance.

If you make the category field an ENUM type then it will automatically be
sorted in the same order as the order of the ENUM values.  Another option
would be to create an additional column (or 2 columns if the same problem
occurs in "subcategory") and assign records with a category of "other" a
value of 1 and assign all other records a default value of 0.  Let's call
the new field "order_1" Then you could construct an ORDER BY clause like:

ORDER BY order_1, category...

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/




---------------------------------------------------------------------
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