Re: problems with different results on count() and select
| From: | Chris Shiflett | Date: | Thu, 16 Sep 2004 15:50:37 +0000 |
| Subject: | Re: problems with different results on count() and select | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196873@lists.php.net to get a copy of this message | ||
--- Merlin <news.groups@web.de> wrote:
> 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
That's some wacky theory. :-)
I think you need to study what the where clause does. Also, what version
of PHP are you using?
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security - O'Reilly
Coming December 2004
HTTP Developer's Handbook - Sams
http://httphandbook.org/
PHP Community Site
http://phpcommunity.org/