SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    May 2004
    Location
    houston
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ordering by priority (different words).

    I need to order by different priority, I have 4 priorities that can be in the field, "urgent", "high", "normal", and "low". I want to grab the urgents first, then high, then normal, and then low.. thats the way they need to be displayed... question is, how can I do this if it is even possible. Otherwise I have to do 4 different queries... Thanks for any help.

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    If you are using MySQL, you can use the ENUM type. Since MySQL is the only language I know, I cannot say how to do in any other language.

    Yours, Erik.

  3. #3
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this...
    Code:
    SELECT * 
    FROM tablename 
    ORDER BY CASE fieldname
    WHEN 'urgent'
    THEN 1 
    WHEN 'high'
    THEN 2 
    WHEN 'normal'
    THEN 3 
    WHEN 'low'
    THEN 4 
    END
    Lats...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •