有没有更有效的方法来做到这一点?我想要使用 PHP 获取给定 MySQL 表中列 (int) 的最大值。
$results = $conn->query("SELECT statement_id FROM statement ORDER BY statement_id DESC LIMIT 1");
$next_statment_id = $results->fetch_assoc();
$next_statment_id = $next_statment_id['statement_id'];
echo $next_statment_id;
最佳答案
MAX也是一个不错的方法
SELECT MAX(statement_id) AS statementIdentity
FROM statement;
输出产生如下内容:-
+-------------------+
| statementIdentity |
+-------------------+
| 4 |
+-------------------+
关于php - 列中的最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35953759/