3
此查詢不起作用。有人能幫助我嗎?一個查詢中有多個計數
$query = "SELECT
COUNT(WHERE Name='george') AS george_total,
COUNT(WHERE Name='michael') AS michael_total,
COUNT(WHERE Name='mike') AS mike_total
FROM users WHERE Banned IS NOT '1' AND Active='yes' AND Logins>1 AND Registered_to_forum='1'";
$row=mysql_fetch_array($result);
echo "
We found $row['george_total'] people with the name 'George' in our database,
$row['michael_total'] with the name Michael
and $row['mike_total'] with the name Mike.
";
謝謝,但它並沒有返回例如喬治的量,它只返回1或0.不是10喬治或類似的東西。 – Jordy
@Jordy - 那麼你只能有一個喬治。兩個查詢都正常工作。也許你是因爲你的「where」條款而排除他們? –
它的工作原理;-)非常感謝! – Jordy