note 47144 added to function.mysql-num-rows

From: Date: Thu, 04 Nov 2004 13:40:36 +0000
Subject: note 47144 added to function.mysql-num-rows
Groups: php.notes 
Request: Send a blank email to php-notes+get-79604@lists.php.net to get a copy of this message
Some user comments on this page, and some resources including the FAQ at : http://www.faqts.com/knowledge_base/view.phtml/aid/114/fid/12 suggest using count(*) to count the number of rows This is not a particularly universal solution, and those who read these comments on this page should also be aware that select count(*) may not give correct results if you are using "group by" or "having" in your query, as count(*) is an agregate function and resets eachtime a group-by column changes. select sum(..) ... left join .. group by ... having ... can be an alternative to sub-selects in mysql 3, and such queries cannot have the select fields replaced by count(*) to give good results, it just doesn't work. Sam ---- Manual Page -- http://www.php.net/manual/en/function.mysql-num-rows.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47144 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47144&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47144&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47144&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47144&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47144&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47144&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47144&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#79604) next »