然后MYSQL订单找出订单号[重复]

Possible Duplicate:
MySQL get row position in ORDER BY

I have a table of users and I want to order them by a column named crown. I then wanted to find out where they are in the list but not totally sure on how to do it. I have tried to Google it but not totally sure on what to type in. (Crown has INT input.)

So I have the first line:

mysql_query("SELECT * FROM users ORDER by crown DESC");

How would I then find out where a user is in the list while ordered by crown?

Thanks in advance.

I'd do something like this, assuming you can get the user's crown value.

SELECT `user_var_you_want`,
       (SELECT COUNT(*) FROM `users` WHERE `crown` > $user_crown_value)+1 AS `position`
FROM `users`
WHERE `user_var_you_want` = $search_value

Or if you can't get their crown value:

SELECT `user_var_you_want`,
       (SELECT COUNT(*) FROM `users` WHERE `crown` > (SELECT `crown` from `users` WHERE `user_var_you_want` = $search_value)+1) AS `position`
FROM `users`
WHERE `user_var_you_want` = $search_value