ok Posted September 14, 2008 Share Posted September 14, 2008 Let say i have this column below name ------ john linda joey george john joseph john I just want to count the total number name of john, So the answer should be 3, can you show me the right SELECT for this please Thank you. Quote Link to comment Share on other sites More sharing options...
phpretard Posted September 14, 2008 Share Posted September 14, 2008 $result = mysql_query("SELECT * FROM table1 WHERE name='john' "); $num_rows = mysql_num_rows($result); echo "$num_rows Rows\n"; ref = http://www.php.net/mysql_num_rows Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 14, 2008 Share Posted September 14, 2008 or, to avoid 'grabbing' all the records and only sending back the COUNT... $result = mysql_query("SELECT COUNT(*) FROM table1 WHERE name='john' "); list($number_of_johns) = mysql_fetch_row($result); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.