开发者

How can I ORDER BY integer data in a MySQL column with the "longtext" data type?

开发者 https://www.devze.com 2023-04-02 08:01 出处:网络
In WordPress, the _postmeta table has a column \"meta_value\" with the \"longtext\" data type. However, I\'m storing integer data i开发者_如何学JAVAn the column and I want to ORDER BY the column by th

In WordPress, the _postmeta table has a column "meta_value" with the "longtext" data type. However, I'm storing integer data i开发者_如何学JAVAn the column and I want to ORDER BY the column by the integers' value.

For example, if I use "ORDER BY meta_value", the result turns out to be something like this:

999
9456
5
123456
111


ORDER BY CAST (meta_value AS DECIMAL)
0

精彩评论

暂无评论...
验证码 换一张
取 消