note 21139 added to function.mysql-num-rows
| From: | bob at bobarmadillo dot com | Date: | Tue, 30 Apr 2002 16:16:22 +0000 |
| Subject: | note 21139 added to function.mysql-num-rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30019@lists.php.net to get a copy of this message | ||
darren@microcyb.com - the best way to resolve your problem would be to do this:
$query = "SELECT count(subid) as count, subid FROM table GROUP BY subid";
$result = mysql_query($query);
based on the following data this would return:
id subid url urlname
1 2 yahoo.com yahoo
2 2 google.com google
3 1 myserver.com server
4 2 anotherserver.com server
+-------+-------+
| count | subid |
+-------+-------+
| 3 | 2 |
| 1 | 1 |
+-------+-------+
it's also a lot less database-intensive to do it this way - using COUNT() instead of
mysql_num_rows.
--
http://www.php.net/manual/en/function.mysql-num-rows.php
http://master.php.net/manage/user-notes.php?action=edit+21139
http://master.php.net/manage/user-notes.php?action=delete+21139
http://master.php.net/manage/user-notes.php?action=reject+21139