本文介绍了MySQL:在“101st"之前对“1st"进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的数据库字段之一中,我有包含序数后缀的数字.我正在尝试对它们进行升序排序,但由于数字包含序数后缀,因此字符串101st"的分配值大于1st",类似地,29th"的值大于2d".
In one of my database fields, I have numbers which include ordinal suffixes. I'm trying to sort them ascending, but since the numbers include ordinal suffixes, the string '101st' is assigned a greater value than '1st', and similarly, '29th' a greater value than '2d'.
有谁知道我可以如何解决这个问题,而不删除每个数字的序数后缀?
Does anyone know how I might work around this, without removing the ordinal suffixes of each digit?
推荐答案
order by cast(field as unsigned)
这篇关于MySQL:在“101st"之前对“1st"进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!