mysql 中前 3 个最大值的序列不正确

Incorrect sequence on top 3 largest value in mysql

我有一个像下面这样的简单脚本

<?php
    $mysqli = new mysqli("localhost","username","password","database");
    $query = "SELECT displayName,benar FROM score ORDER by benar DESC LIMIT 3";
    if ($result = $mysqli->query($query)) {
        while ($row = $result->fetch_assoc()) {
            $output[] = array(
            'displayName' => $row["displayName"],
            'benar' => $row["benar"],
            );
        }
        $result->free();
    }
    $mysqli->close();
echo json_encode($output, JSON_PRETTY_PRINT);    
?>

并且从上面的脚本中需要一个mysql数据库,下面的数据库

+++displayName+++++++benar+++
+    Georgio     +    592   +
+     Mark       +    103   +
+    Daniel      +    850   +
+     Samuel     +    1100  +
+     Rudy       +    900   +
+++++++++++++++++++++++++++++

在我对上述数据库使用我的脚本后,我得到如下输出

[
    {
        "displayName": "Rudy",
        "benar": "900"
    },
    {
        "displayName": "Daniel",
        "benar": "850"
    },
    {
        "displayName": "Samuel",
        "benar": "1100"
    }
]

如你所见,1100的值在最后一部分,1100这个数字应该在最前面,有什么解决这个问题的建议吗?谢谢

将列中的数据类型更改为 "integer",目前它将是某种形式的文本,因此从第一个字符开始读取,这意味着正在发生类似以下的事情;

9 > 8 > 1

因此更改数据类型将使其正确读取;

ALTER TABLE `score` MODIFY `benar` INT;

查看此处寻求帮助; https://dev.mysql.com/doc/refman/8.0/en/alter-table.html