Do it in two separate queries:
$db->query('SET @rownum := 0');
$sql = 'SELECT @rownum :=@rownum + 1 AS Rank, User_Id, COUNT(User_ID) AS Block_Count FROM Block_Owners'
$stmt = $db->prepare($sql);
$stmt->bind_param('ii', $world, $userId);
$stmt->execute();
Note, however, that the query you want to run will always return a single row (with Rank = 1
) since you are using an aggregate function without GROUP BY
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…