Page 1 of 1
How many in table?
Posted: Mon Apr 18, 2005 12:15 pm
by Dale
Ok, now i know this must be a basic command, but how do i get it to print the amount of rows in a table? (eg; dale_houses)
Posted: Mon Apr 18, 2005 12:41 pm
by John Cartwright
Code: Select all
SELECT COUNT(*) AS `total` FROM `table`
Posted: Tue Apr 19, 2005 2:42 pm
by vigge89
Justa tiny question, are there any differences in speed count()-ing all the fields (*), or just one field? That is, if all rows has the field set.
Posted: Wed Apr 20, 2005 3:28 am
by phpScott
probably, but that would depend on how many columns are in the table and whether the column you count has been indexed.
Posted: Wed Apr 20, 2005 4:44 am
by malcolmboston
from what i have read in the past
the difference between mysql_num_rows + the count method is very little except on large tables where count is recommended
personally i use num_rows method on small tables and count on large tables
also, num_rows requires less lines of code to retrieve the value...
hope that helps
Posted: Wed Apr 20, 2005 9:16 pm
by fractalvibes
Seems like a select count(*) from sometable would be optimized to
use a primary key index and be quicker....guess it depends...
fv