mysql ORDER BY help

Discussion in 'PHP' started by webmaster_TSU, May 27, 2008.

  1. #1
    I have a field, status, that can be either:

    ACCEPTED
    REJECTED
    In Process
    PAID on [date paid]

    I want to order results like this:

    ORDER BY FIELD(status, 'In Process', 'ACCEPTED', 'PAID', 'REJECTED')

    So In Process would be on top, followed by accepted, then paid, and finally rejected. However, the ones that are PAID also have a date, and this doesn't work. Can I use regular expressions to solve the problem?
     
    webmaster_TSU, May 27, 2008 IP
  2. mehmetm

    mehmetm Well-Known Member

    Messages:
    134
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Hi,

    I guess it is related to that you use 'PAID', but the value in the field not just 'PAID' huh ?
    that is the why 'PAID' comes first..

    You can do another field named by 'paiddate' and insert the date paid value in here. And the just 'PAID' goes to status field..
     
    mehmetm, May 27, 2008 IP
  3. webmaster_TSU

    webmaster_TSU Peon

    Messages:
    449
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah, I think I really should do that because tacking the date on to the end really isn't the right way to do it.
     
    webmaster_TSU, May 28, 2008 IP