数据排序问题

比如数据库中字段为“端口”中保存着如下数据
3/1 3/2 3/3 3/4 3/5 3/5 3/6 3/7 3/8 3/9 3/10 3/11 3/12 3/13 ...

我用select * from table order by 端口
读出数据后则显示
3/1
3/10
3/11
3/12
3/13
……
3/2
3/3
3/4
3/5
3/6
3/7
3/8
3/9

可是我想让它显示为
3/1
3/2
3/3
3/4
3/5
3/6
3/7
3/8
3/9
3/10
3/11
3/12
3/13
……
请问该如何处理。
---------------------------------------------------------------

取出后排序,可用natsort函数

mysql中,sql串可写作
select 端口,replace(端口,'/','0')+0 as p from table order by p
就是先将串化为数字然后排序

Published At
Categories with Web编程
Tagged with
comments powered by Disqus