Re: determining number of rows in a mysql table

From: Date: Tue, 30 Mar 2004 02:30:28 +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-181764@lists.php.net to get a copy of this message
chris.t.wagner.1@ohiou.edu (Chris Wagner) wrote in news:1080612746.2601.6.camel@dhcp-mobile-245-225.newcastle.edu.au: > this should be easy... > > how would one go about determining the number of rows in a mysql table, > without actually wasting the time of querying for *. > > is this the best way? > > $result = mysql_query('SELECT * FROM tablename'); > $num_rows = mysql_num_rows($result); > > does this actually take up time searching? > > thanks. > Try SELECT COUNT(*) FROM table AS numrows Have a look at http://www.mysql.com/doc/en/GROUP-BY-Functions.html for more info on how Count works.

« previous php.general (#181764) next »