我正在查看最后 3 行是否具有相同的 userId ...我尝试过计数,选择 distinct 没有运气。有任何想法吗?
id userId gameId switchId won
--------------------------------
1 1515 5 475 0
2 1515 5 475 0
3 1515 5 475 0
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
$st = $db->prepare("SELECT COUNT(userId) AS total FROM arcadeGamesInPlay WHERE userId=:userid,gameId=:gameId AND switchId=:switchId AND won=:won ORDER by id DESC LIMIT :limit"); // need to filter for next auction
$st->bindParam(':userId', $userId);
$st->bindParam(':gameId', $gameId);
$st->bindParam(':switchId', $switchId);
$st->bindParam(':won', $won);
$st->bindParam(':limit', $limit);
$limit=3;
$won=0;
$st->execute();
$r = $st->fetch(PDO::FETCH_ASSOC);
$playedLastThreeGames= $r['total'];