On Mon, 12 Jan 2004, Lewis, Jason wrote:

> Okay I have a field in my db called MemberLevel in this field you can be one of 5 
> levels.
>
> Platinum
> Gold
> Silver
> Paying
> Non-Paying
>
>
> now my question is, how would I ORDER BY MemberLevel and get it to come out in the 
> above order? I have been racking my brains for a week on this one and any help will 
> be appreciated.
>

Can think of 3 options offhand.

1. ENUM() and order by enumcol, this will order them in the order you
specify them in the ENUM('col1', ...) order.

2. Break it out into another table andgive them ids in the order they
should be sorted

3. use a CASE statement:
SELECT col, CASE col WHEN 'Platinum' THEN 1 WHEN 'Gold' THEN 2 ... END AS
sortby ORDER BY sortby


cheers,
Tobias

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to