Re: How many rows in a table



Andy Hassall wrote:
On Sat, 30 Dec 2006 17:04:58 -0500, bill <nobody@xxxxxxxxxxx> wrote:

I am sure there must be an easy way to determine the number of rows in a table, but I can't find it.

I appreciate the courtesy and patience ng members have shown this mysql novice.

select count(*) from your_table


$total_rows = mysql_query ("SELECT COUNT(*) FROM Kennel");

gives me a resource, not the count.

Fine, so I use:

$total_rows = mysql_query ("SELECT COUNT(*) FROM Kennel");
echo "Rows in table: " . mysql_num_rows ($total_rows) . "<br />";

but that returns 1, and there are 4 rows in the table.
However,

$sql = "Select id, kennel_name, location, real_names from Kennel
ORDER BY REPLACE(kennel_name,'The ','') LIMIT 100";
$result = mysql_query($sql, $connection) or die(mysql_error());
echo "Rows in table-2: " . mysql_num_rows ($result) . "<br />";

does give the correct answer.

what am I doing wrong with the first query ?
.



Relevant Pages

  • Re: How many rows in a table
    ... I appreciate the courtesy and patience ng members have shown this ... mysql novice. ...
    (comp.lang.php)
  • Re: How many rows in a table
    ... I appreciate the courtesy and patience ng members have shown this mysql novice. ... If you fetched the first row with mysql_fetch_array or one of the variants of ...
    (comp.lang.php)
  • How many rows in a table
    ... I appreciate the courtesy and patience ng members have shown this mysql novice. ...
    (comp.lang.php)
  • Re: cell phones on rides
    ... As for the courtesy, loud cell phone conversations are at least one-sided, I've been on many a ride where I was forced to drop back or endure an endless conversation between two or more riders. ... Two members thought spin class was spin and talk class and of course you can't xactly distance yourself from the group in that instance. ...
    (rec.bicycles.misc)
  • Re: BN / Marine Conservation Soc walks - dangers?
    ... Steve ... your courtesy. ... forwarded my questions on to the chairperson and also Andrew Welch. ... loose members and fail to attract new or old members back. ...
    (uk.rec.naturist)