» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > MySQL Forums

MySQL Forums Share Your Ideas and Tips about MYSQL. Ask questions about MYSQL. Table Design and Much More...

Reply
 
Thread Tools Display Modes
  #1  
Old 08-04-2006, 10:18 AM
Caiden Caiden is offline
Junior Member
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Caiden is on a distinguished road
Default /table ranking/

I have a table with (id, score) and i m trying to write a query that will return the rank of a certain id ranked by order of score.
i got this far;

SET @i = 0;
SELECT id, @i:=@i+1 AS rank
FROM scores
ORDER BY score DESC;

which returns a table of ranks which is correct but i need to select just one of those rows specified by an id. Any ideas? -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 08-04-2006, 10:22 AM
ishac ishac is offline
Senior Member
 
Join Date: Jul 2006
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 18
ishac is on a distinguished road
Default

SET @i = 0;
SELECT id, @i:=@i+1 AS rank
FROM scores
WHERE id = 55
ORDER BY score DESC;

If you need to select by rank you would have to use HAVING

SET @i = 0;
SELECT id, @i:=@i+1 AS rank
FROM scores
HAVING rank = 34
ORDER BY score DESC; -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
i m facing ranking problems jig123 Yahoo 5 07-22-2008 10:10 AM
it will bump it higher in the ranking. ziga Google 7 09-22-2006 05:52 PM
what can i do for good ranking in yahoo? DANNIAL Yahoo 40 09-18-2006 02:07 PM
yahoo ranking -ups and downs yorke Yahoo 2 06-23-2006 03:10 PM
ranking higher for msn kirti MSN 1 12-11-2005 07:43 AM


All times are GMT. The time now is 11:01 AM.