Tom Gillespie Tom Gillespie - 6 months ago 16x
SQL Question

How can I echo a COUNT query

I'm new to mySQL and as such am just looking for a very simple COUNT query which I haven't found explained online with any real clarity.

What I'm looking to do is

COUNT the number of rows in my PASSENGER table where groupID = 0, and then be able to echo the numerical value that the count will return, how can I do this?


Something like this

$query = "SELECT COUNT(*) c FROM PASSENGER WHERE groupID = 0;";
$result = mysql_query($query);
$row = mysql_fetch_assoc($query);
echo $row['c']; //Here is your count