Re: determining number of rows in a mysql table

From: Date: Tue, 30 Mar 2004 02:24:59 +0000
Subject: Re: determining number of rows in a mysql table
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-181762@lists.php.net to get a copy of this message
Hello Chris, Tuesday, March 30, 2004, 3:12:26 AM, you wrote: CW> how would one go about determining the number of rows in a mysql table, CW> without actually wasting the time of querying for *. CW> is this the best way? CW> $result = mysql_query('SELECT * FROM tablename'); CW> $num_rows = mysql_num_rows($result); SELECT COUNT(*) AS hits FROM tablename The row count will be in "hits" in $result. Count is a much faster way for MySQL to give you the number you want without actually selecting all the data in the process. -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html

« previous php.general (#181762) next »