开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜