以下数据的排序。

时间:2014-05-06 10:06:45

标签: php mysql sql facebook twitter

如何对数据进行排序

Black Tiger / HL / Regular G2 - 10x2000/2000 - 13/15 ()<br>
Black Tiger / HL / Regular G2 - 10x2000/2000 - 16/20 ()<br>
Black Tiger / HL / Regular G2 - 10x2000/2000 - 21/25 ()<br>
Black Tiger / HL / Regular G2 - 10x2000/2000 - 3/6 ()<br>
Black Tiger / HL / Regular G2 - 10x2000/2000 - 8/12 ()<br>
Black Tiger / HL / Regular G2 - 6x2000/2000 - 13/15 (0)<br>
Vannamei / HOSO / Regular - 10x800/1000 - 31/40 (50)<br>
Vannamei / HOSO / Regular - 10x800/1000 - 40/60 (75)<br>
Vannamei / HOSO / Regular - 10x800/1000 - 61/80 (100)<br>
Vannamei / HOSO / Horeca - 10x800/1000 - 8/12 (15)<br>
Vannamei / HOSO / Horeca - 10x800/1000 - 13/15 (18.75)<br>
Vannamei / HOSO / Horeca - 10x800/1000 - 16/20 (25)<br>
Vannamei / HOSO / Horeca - 10x800/1000 - 21/25 (31.25)<br>
Vannamei / HOSO / Horeca - 10x800/1000 - 26/30 (37.5)<br>

应按

排序
Black Tiger / HL / Regular G2 - 10x2000/2000 - 3/6 ()<br>
Black Tiger / HL / Regular G2 - 10x2000/2000 - 8/12 ()<br>
Black Tiger / HL / Regular G2 - 10x2000/2000 - 13/15 ()<br>
Black Tiger / HL / Regular G2 - 10x2000/2000 - 16/20 ()<br>
Black Tiger / HL / Regular G2 - 10x2000/2000 - 21/25 ()<br>
Vannamei / HOSO / Horeca - 10x800/1000 - 8/12 (15)<br>
Vannamei / HOSO / Horeca - 10x800/1000 - 13/15 (18.75)<br>
Vannamei / HOSO / Horeca - 10x800/1000 - 16/20 (25)<br>
Vannamei / HOSO / Horeca - 10x800/1000 - 21/25 (31.25)<br>
Vannamei / HOSO / Horeca - 10x800/1000 - 26/30 (37.5)<br>
Vannamei / HOSO / Regular - 10x800/1000 - 31/40 (50)<br>
Vannamei / HOSO / Regular - 10x800/1000 - 40/60 (75)<br>
Vannamei / HOSO / Regular - 10x800/1000 - 61/80 (100)

1 个答案:

答案 0 :(得分:1)

您可以通过以下查询获得结果,但如果有大量数据,查询将会很慢。

SELECT * FROM mytable ORDER BY LEFT(myfield,5), SUBSTRING_INDEX(SUBSTRING_INDEX(myfield,'-',-1),'/',1);