Select Distinct Counting

Hi,

I have a database with roughly 73k rows (records). I am using a query string such as:
SELECT DISTINCT Column FROM databasename

I am then using mysql_num_rows($results) to count the number of distinct rows. This method works, but it is slow.

Is there a faster way of doing this perhaps internal to the mysql without having to send the entire results to the PHP when I only need a count?

[php]
$result = mysql_query(“SELECT COUNT(id) FROM users”) or die(mysql_error());
$row = mysql_fetch_array($result);
echo"{$row[‘COUNT(id)’]}";
[/php]
I am not certain if it is faster but you can give that a shot, :smiley: I am just not gonna take the time to test them out and see if it is faster 8) But just replace id with whatever field/column name you got and users with whatever table name you got and make sure and come back and let me know if it is faster or not! ;D

Sponsor our Newsletter | Privacy Policy | Terms of Service