用int Mysql排序问题 [英] Order By problem with int Mysql

查看:28
本文介绍了用int Mysql排序问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我订购,我在数据库中将价格设为 INT

I have prices in a database as INT if I order by I get

97,650

出现之前结束

975,455

after sorting in DESC

看来,由于第一个价格中的 6 大于第二个价格中的第 3 位位置,因此将其视为更大的数字.

It appears that since the 6 in the first price is greater than the 3rd place position in the second price, it counts that as a larger number.

有没有人遇到过这个问题并且知道如何解决它?

Has anyone run into this problem and know how to solve it?

推荐答案

要测试,试试这个缓慢而悲伤的查询.

To test, try this slow and sad query.

select prices from (table) order by (prices+0);

如果该查询有效,那么您的列很可能不是 INT 列.(prices+0) 确保数据被视为整数.

If that query works, then it is likely your column is not an INT column. The (prices+0) makes certain that the data is treated as an integer.

一旦您发现这确实对您有用,您就需要将该列更改为 INT 列.

Once you have found that this does indeed work for you, you need to alter the column to be an INT column.

这篇关于用int Mysql排序问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆