我有距离的数据,比如
5-10,0-5,10-15,
我使用此查询来按排序顺序获取数据:
$this->db->select("distance_from_mall");
$this->db->from("transport_charges");
$this->db->order_by("distance_from_mall", "asc");
$route =$this->db->get()->result_array();
它给了我
0-5,10-15,5-10代替0-5 ,5-10,10-15,
发布于 2014-08-06 22:21:44
因为你的距离是一个字符串,引擎ORDER
s它作为一个字符串。
这就是对此查询的正确响应。
我建议将每个transport_charge
的distance
更改为最小整数/数字。如果范围不重叠,这将为您提供所需的所有数据。
如果是这样的话,将distance
存储为两列,range_max
和range_min
,以及ORDER BY
中更有意义的一列,或者将这两列分别存储:ORDER BY range_min, range_max
https://stackoverflow.com/questions/25162769
复制相似问题