PHP mysql顺序从标题的右边的数字


php mysql order by numbers from right of title

我需要从标题结束的数字排序,但需要作为UNSIGNED结果,我尝试从标题表和排序中获得最后5位数字,但不给出自然结果

标题表

title1 (2015)
something (1999)
title1 (1994
title1 (2014)

我的代码
 ORDER BY RIGHT(title,5) DESC
结果

something (1999)
title1 (1994)
title1 (2014)
title1 (2015)

我怎样才能这样订购呢?

title1 (2015)
title1 (2014)
something (1999)
title1 (1994)

现在这个代码顺序是1,10,101 2,20,201但是我需要像这样1,2,10,20,101,201

因为您是子字符串,所以它将数据转换为文本。

您需要将其转换回number(源):

order by substring(title,-5,4)*1 desc;

如果你这样做呢?查看这里的演示

select col1 from table1
order by replace(right(col1,5), ')','') desc;

你需要ORDER BY ASC而不是DESC

ORDER BY RIGHT(title,5) ASC