This query doesn’t work. Can someone help me please?
$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.
";
You can use a
CASEstatement and eitherCOUNTorSUM.The
COUNTversion is below.COUNTonly countsNOT NULLvalues so you can use any Non Null column or constant instead of 1.The
SUMversion is