【发布时间】:2015-08-12 17:23:06
【问题描述】:
我有字段名称“codehead”,其值类似于
"53/066/10"
"54/066/05"
"56/066/09"
"52/069/15"
"53/069/02"
"67/069/02"
"00/020/80"
"00/020/98"
我希望结果按以下顺序排列
"00/020/80"
"00/020/98"
"53/066/05"
"53/066/10"
"54/066/09"
"52/069/15"
"53/069/02"
"67/069/02"
我尝试过类似的查询
$data= mysql_query("select codehead,sign, SUM(amt) as amt from pm where month='$pmmonth' and rc='R' GROUP BY substr(codehead,4,3) ASC,substr(codehead,7,2) ASC, sign ")
但无法得到完整的结果。
【问题讨论】:
-
请stop using
mysql_*functions。它们不再被维护并且是officially deprecated。改为了解 prepared statements,并考虑使用 PDO,it's not as hard as you think。
标签: php mysql sorting substring