如果是非中文的字符,那么就用:
ORDER BY case WHEN spec_array like '%str_01%' then 1 WHEN spec_array like '%str_02%' then 2 WHEN spec_array like '%str_03%' then 3 WHEN spec_array like '%str_04%' then 4 WHEN spec_array like '%str_05%' then 5 WHEN spec_array like '%str_06%' then 6 WHEN spec_array like '%str_07%' then 7 WHEN spec_array like '%str_08%' then 8 end asc
如果是按照中文来排序,那么用这段之前要加上一句:
mysql_query("SET NAMES 'utf8'"); mysql_query("SET CHARACTER_SET_CLIENT=utf8"); mysql_query("SET CHARACTER_SET_RESULTS=utf8");
ORDER BY case WHEN spec_array like '%str_01%' then 1 WHEN spec_array like '%str_02%' then 2 WHEN spec_array like '%str_03%' then 3 WHEN spec_array like '%str_04%' then 4 WHEN spec_array like '%str_05%' then 5 WHEN spec_array like '%str_06%' then 6 WHEN spec_array like '%str_07%' then 7 WHEN spec_array like '%str_08%' then 8 end asc