mysql order by 排序按指定值的顺序,没有查询结果也占位
SELECT * FROM (
SELECT 'new' AS status
UNION
SELECT 'in_progress'
UNION
SELECT 'completed'
) AS status_list
LEFT JOIN my_table ON my_table.status = status_list.status
ORDER BY FIELD(status_list.status, 'new', 'in_progress', 'completed');