Click to See Complete Forum and Search --> : count bg numbers


patimages
07-25-2007, 05:14 AM
Hi,

I have a mysql table with about 400,000 rows and sevral coulums. If I search using php for "a", the expected number of matches is above 260,000 and I get a "Warning: mysql_query() [function.mysql-query]: Unable to save result set". I guess it is too much. However, I just would like to count the matches, not display them... Is there a way to count my matches anyway ?

thanks for any help !

I use :
$data = mysql_query("SELECT * FROM tab WHERE upper($field) LIKE'%$query%'");
$anymatches=mysql_num_rows($data);

bubbisthedog
07-25-2007, 02:31 PM
All you gots to do is add the COUNT() aggregate function to the field set:

select count(*) from tab where upper($field) like '%$query%'

Then just use mysql_fetch_array() to get the result.