Re: problems with different results on count() and select

From: Date: Thu, 16 Sep 2004 09:19:52 +0000
Subject: Re: problems with different results on count() and select
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-196841@lists.php.net to get a copy of this message
Thomas Seifert wrote:
On Thu, 16 Sep 2004 10:43:46 +0200, Merlin wrote:
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?
It can't be the same number as you are using a where clause in the second statement so you are missing some rows there. also your code for ordering in the first part might just be wrong, but you didn't show this code. thomas
Hi, the where clause is a replacement for the order by clause in the first statement. Inside this first select statement I am showing 20 results on each page with the limit command as shown here: SELECT
    u.user_name,
FROM
    usertable
ORDER BY
    points desc, registration_date desc
Limit 20, 40 This should show the members ranked 20 - 40 On the other page I would just like to know which user rank this person has: But it is never the same as on the other page SELECT count(*) AS c FROM
    usertable
WHERE
    points > '$points'
    AND registration_date > '$date'
Any ideas? Merlin

« previous php.general (#196841) next »