MAX 函数的查询结果不起作用

问题描述 投票:0回答:0

我有一张“测试”表。有一列叫做年龄。我正在尝试从年龄中获取最大值并将该值用作另一个查询的变量($result2)。它没有给出任何输出。这个查询有什么问题。

$sql="select max(age) from Test where id='$id'";
$query = $dbh->prepare($sql);
$query->bindParam(':id',$id,PDO::PARAM_STR);
$query->execute();
$result3=$query->fetchAll(PDO::FETCH_OBJ);
$result2=$result3->age;
php mysql mysqli pdo
© www.soinside.com 2019 - 2024. All rights reserved.