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. Link to comment https://forums.phpfreaks.com/topic/124163-very-basic-query/ 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 Link to comment https://forums.phpfreaks.com/topic/124163-very-basic-query/#findComment-641025 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); Link to comment https://forums.phpfreaks.com/topic/124163-very-basic-query/#findComment-641033 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.