订单状态有 -1,0,1,2,3,4,5,7
需求:排序按照0,1,2,3,7,4,5,-1
SELECT * FROM shop_order ORDER BY ( CASE `status` WHEN 0 THEN 1 WHEN 1 THEN 2 WHEN 2 THEN 3 WHEN 3 THEN 4 WHEN 7 THEN 5 WHEN 4 THEN 6 WHEN 5 THEN 7 WHEN - 1 THEN 8 END)
说明 :WHEN将某个值放到THEN的位置
订单状态有 -1,0,1,2,3,4,5,7
需求:排序按照0,1,2,3,7,4,5,-1
SELECT * FROM shop_order ORDER BY ( CASE `status` WHEN 0 THEN 1 WHEN 1 THEN 2 WHEN 2 THEN 3 WHEN 3 THEN 4 WHEN 7 THEN 5 WHEN 4 THEN 6 WHEN 5 THEN 7 WHEN - 1 THEN 8 END)
说明 :WHEN将某个值放到THEN的位置