Reply to Re: Get possition

Your name:

Reply:


Posted by Jerry Stuckle on 08/26/05 00:08

I_love_php wrote:
> hello i have this table
>
> (USERS )
> witch have
> game_id
> user_id
> points
>
>
> ---------
>
> in every game user can win points ... what i want is the best way to
> Get the position of the user
>
> lets say i want to get the position of the user number 24 ...(up to the
> points ) higher points in the Frist and the lowest points in the last
>
> Thanks in advance
>

You didn't say which database or version you're running, but if it supports
subselects something like this might work (warning - not tested):

SELECT count(user_id) FROM table WHERE points > (SELECT points FROM table
WHERE user_id = 24);

Then add 1 to get the user's position. Don't use >= because your user might be
tied with 20 other users - and you'll get an incorrect result.

If your database doesn't support subselects, just do this in two different
SELECT statements (get the points for user_id=24 and use it in the WHERE clause
of the first select).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация