counting records in db

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi!

what would be better solution to count records in table (e.g., how many
customers have last name 'Smith'):

$query = mysql_query("
		SELECT COUNT(*) as NoOfRecords
		FROM customers
		WHERE last_name = 'Smith'");
$result = mysql_fetch_array($query);
$NoOfRecords = $result['NoOfRecords'];

OR

$query = mysql_query("
		SELECT cust_id
		FROM customers
		WHERE last_name = 'Smith'");
$NoOfRecords = mysql_num_rows($query);

OR something else?

Thanks.

-afan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux