php - mysql order by multiple value in specific order -


there 1 table called projects details. projects

id | status |name  1  | red | prj1 2| amber | prj2 3| green | prj3 4| red | prj4 5|completed  | prj5 6|amber  | prj6 7|green  | prj7 5|completed  | prj8 

using mysql-can arrange in specific order. result needed show projects in red @ first place green , amber after completed

thanks in advance

just use expression in order by:

order (case when status = 'red' 1 when status = 'green' 2 else 3 end) 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -