我有一个名为 donations
的表,其中包含用户的每次捐赠 - 就像这样:
uid|month|year|what donate
我尝试在此表中获取一些 uid
位置但是在特定的月份和年份。这是我的代码:
$table = $mysqli->prepare('SELECT count(*) AS counter FROM donations WHERE uid = ? AND month = ? AND year = ? GROUP BY uid LIMIT 1');
$table->bind_param('iii', $uid, $month, $year);
$table->execute();
$table->bind_result($count);
$table->store_result();
$rows = $table->num_rows;
$table->fetch();
count
返回用户在我选择的日期内捐赠了多少次,但不返回他在 donations
表中的位置。有人看到问题了吗?
最佳答案
这应该有效。
SELECT count(*) AS counter
FROM donations
WHERE month = '01' AND year = '2019'
GROUP BY uid
ORDER BY counter desc;
关于php - 从捐款表中选择用户职位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54069162/