select count(*) with mysql is one too large
Posted on 2004-08-07
When I run the following:
$recordCount = "select count(*) from memberInfo where lname like 'B%'";
$totalRowsResult = mysql_query($recordCount,$conn);
$totalRows = mysql_fetch_row($totalRowsResult);
$totalRows = 25. However, if I run select * from memberInfo where lname like 'B%' it returns 24 records. Why is select count(*) counting one too many when run within PHP? If i run both queries from the MySQL client, they both indicate that there are 24 rows. Do I just always have to subtract one from whatever is returned when I do select count(*) from PHP?