gpt4 book ai didi

php - mysql 从表中获取行号,其中列值等于特定值

转载 作者:行者123 更新时间:2023-11-29 18:40:53 25 4
gpt4 key购买 nike

我有一个表,其中模型测试的结果按降序排列在列中。现在我想获取特定行的行号。这是示例表:

enter image description here

因此,当我使用 userid=44 搜索 a 时,它应该返回 3。同样,当我使用 userid=11 搜索时,它应该返回 4。我该怎么做?如果有人可以帮助我的话。

最佳答案

例如:

$stmt = PDO::prepare('SELECT id FROM table WHERE userid = ?');
$userId = 44;

$stmt->execute([$userId]);
$result = $stmt->fetch(PDO::FETCH_OBJ);

echo $result->id;

http://php.net/manual/en/book.pdo.php

关于php - mysql 从表中获取行号,其中列值等于特定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44948841/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com