关于mysql中orderby的几个注意事项

来源:互联网 发布:网络电视盒子排名 编辑:程序博客网 时间:2024/05/21 10:04

在mysql+php查询中 对字段的类型要求比较高 例如varchar(11)和int 这两种类型 在许多时候可以通用但是在下面这种情况时候最好还是选择int而不要选择varchar(11)

table list

字段名   类型

id       int    auto_increment

list_id  varchar(11)

content  varchar(50000)

请先看上面的几个字段 在php中使用sql进行查询时

eg  a:select * from tablelist order by list_id asc  

eg  b:select * from tablelist order by id asc

这两个语句查询时查询的结果会有所差异

eg a  的结果 查询出来的顺序是 1,10,11,2,21,23,3,4,5

eg b 的寄过 查询出来的顺序是 1,2,3,4,5,6,7,8,9,10

菊子曰 这就是菊子曰啦!
原创粉丝点击