如何在sql中从数据库中选择表中列值最高的位置

  • 本文关键字:位置 选择 sql 数据库 php sql
  • 更新时间 :
  • 英文 :


我有这个表,有一些数据,但我想得到的行,其中一个特定的列votecount具有最大值:

<表类> id votecount tbody><<tr>102131413

试试这个:

$selectr = "SELECT * from `audio` where `votecount` = ( SELECT MAX(`votecount`) from `audio`)"; 
$stmt = $conn->prepare($selectr);
$stmt->execute([]);
while($row = $stmt->fetch())
{
$userid = $row["id"];
$votecount = $row["votecount"];
echo $userid;
echo $votecount;
}

试更正:$userid = $row[">userid");to $userid = $row[">id"]

最新更新