how about :
SELECT (count( b.unique_id ) + 1) ranking
FROM table_name a, table_name b
WHERE a.unique_id = '4' AND b.score > a.score
Mike wrote:
Let's say I have a database and I want to find the position of a row when it is
ordered by a specific column
before a sort:
UNIQUE ID | SCORE
1 | 100
2 | 50
3 | 30
4 | 80
5 | 50
after sort:
UNIQUE ID | SCORE
1 | 100
4 | 80
2 | 50
5 | 50
3 | 30
is it posible to find the position of 4 with a query or mysql function?
Normally I'd just 'SELECT unique_id FROM table ORDER DESC' then loop through
the results looking for a matching id, however my table contains thousands of
entries, and it's simply not possible do do it that way.
Thanks
Mike
--
Tatang Widyanto
Unit Pengkajian dan Penerapan Teknologi Informasi
Universitas Brawijaya
http://www.brawijaya.ac.id
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php