更新时间:2023-08-31 19:05:40
看起来值是字符串,它选择了最大字符串.如果要对它们进行数字排序,则必须先将它们转换为数字.您可以使用转换进行此操作:
Looks like the values are strings and it selecting the maximum string. You have to cast them to numbers first if you want them to sort numerically. You can use CONVERT to do this:
SELECT MAX(CONVERT(id, SIGNED)) FROM table
您还可以使用 CAST :
SELECT MAX(CAST(id AS SIGNED)) FROM table
除了CONVERT
如果需要它们还有一些其他选择之外,它们几乎做同样的事情.
They do nearly the same thing except CONVERT
has some additional options if you need them.