Re: MYSQL row position.. is it possible (urgent)

From: Date: Mon, 07 Mar 2005 06:58:02 +0000
Subject: Re: MYSQL row position.. is it possible (urgent)
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-38790@lists.php.net to get a copy of this message
how about : SELECT (count( b.unique_id ) + 1) ranking FROM table_name a, table_name b WHERE a.unique_id = '000000004' 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 000000001 | 100 000000002 | 50 000000003 | 30 000000004 | 80 000000005 | 50 after sort: UNIQUE ID | SCORE 000000001 | 100 000000004 | 80 000000002 | 50 000000005 | 50 000000003 | 30 is it posible to find the position of 000000004 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

« previous php.db (#38790) next »