MYSQLI使用ORDER BY时的逻辑排序

时间:2015-09-11 14:34:20

标签: mysql sql sql-order-by

如何通过逻辑订购买家编号获得订单?

查询:

SELECT * FROM $auction_id ORDER BY buyer_num

结果:

> 1 2 23 3 32 4 5 6 62 7 8 9 10

我需要输出的结果:

> 1 2 3 4 5 6 7 8 9 10 23 32 62

1 个答案:

答案 0 :(得分:0)

看起来您已将buyer_num定义为字符串而不是整数。如果你想把它排序好像是一个数字,你可以说

ORDER BY CONVERT(buyer_num, SIGNED INTEGER)

https://dev.mysql.com/doc/refman/5.0/en/cast-functions.html#function_convert