I have a MySQL table with many rows. The table has a popularity column. If I sort by popularity, I can get the rank of each item. Is it possible to retrieve the rank of a partic
hobodave's solution is very good. Alternatively, you could add a separate rank column and then, whenever a row's popularity is UPDATE
d, query to determine whether that popularity update changed its ranking relative to the row above and below it, then UPDATE
the 3 rows affected. You'd have to profile to see which method is more efficient.