-2

我试过这样的事情:

    $changed = mysql_query("SELECT * FROM games WHERE changed = 'y' AND human = '$_GET[human]' ORDER BY id DESC LIMIT 100", $link);
$num_rowsc = mysql_num_rows($changed); 

所以我想要的是选择最后 100 个人类 = 是的,然后计算改变的地方 = y ..

所以找最后 100 个人,数一数他们中有多少人发生了变化,是的

4

4 回答 4

2

也许用这个查询?

SELECT COUNT(*) AS cnt FROM (
    SELECT * FROM games 
    WHERE human = '".mysql_real_escape_string($_GET[human])."'
    ORDER BY id DESC LIMIT 100
) tmp WHERE changed = 'y'
于 2013-10-13T20:16:22.580 回答
2

您是否正在寻找这样的东西:

$stmt = $pdo->prepare("SELECT COUNT(*) AS cnt FROM ( SELECT * FROM games 
                        WHERE human= :human ORDER BY id DESC LIMIT 100
                        ) WHERE changed = 'y' ");
$stmt->bindParam(':human', $_GET[human]);
$stmt->execute();
于 2013-10-13T20:22:48.247 回答
1

1)尝试使用它作为您的查询:
SELECT count(*) FROM (SELECT * FROM games WHERE changed = 'y' ORDER BY id DESC LIMIT 100) WHERE human = '$_GET[human]'
2)使用mysqli

于 2013-10-13T20:17:49.423 回答
1
select count(*) as cnt from (
SELECT human FROM games WHERE human = '$_GET[human]' ORDER BY id DESC LIMIT 100
) as changes WHERE changed = 'y'
于 2013-10-13T20:18:54.117 回答