MySQL Forums
Forum List  »  Newbie

Re: How to define TOP 5 records?
Posted by: Felix Geerinckx
Date: June 15, 2005 07:58AM

Sergei wrote:

> For example, we have some records of votings for users:
> ...
> -- but I suppose that the right result should be
> ...
> -- cause we have users with the same votings
>
> What should I do to find out the solving.

You need a temporary table:

DROP TABLE IF EXISTS temp_ttt;
CREATE TEMPORARY TABLE temp_ttt SELECT vote FROM ttt ORDER BY vote DESC LIMIT 5;
SELECT ttt.uid, ttt.uname Best, ttt.vote
FROM ttt
JOIN temp_ttt ON temp_ttt.vote = ttt.vote
ORDER BY ttt.vote DESC;

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
June 15, 2005 07:37AM
Re: How to define TOP 5 records?
June 15, 2005 07:58AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.