problems with different results on count() and select
| From: | Merlin | Date: | Thu, 16 Sep 2004 08:43:46 +0000 |
| Subject: | problems with different results on count() and select | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-196832@lists.php.net to get a copy of this message | ||
Hi there,
I am having difficulties to order user into a ranking table. In the listing of the users I use a select statement, where I order after points and registration date. Then I print out thre results counting the rows. 1,2,3...
SELECT
u.user_name,
FROM
usertable
ORDER BY
points desc, registration_date desc
on another page the user can access his user rank directly. Here I am using a count statement where I count all users who have more points than the member and have registered earlier (to avoid results with members having the same points)
SELECT count(*) AS c
FROM
usertable
WHERE
points > '$points'
AND registration_date > '$date'
Theoreticly the result number of the first select statement should be identical with the count statement, but it is not.
Has anybody an idea how to fix that?
Thanx in advance,
Merlin