[SOLVED] MySQL position of a row
Posted: Sat Jul 29, 2006 5:04 am
Here's an example table:
I want to find out how many rows deep row this row is:
x could be 10 000 for example.
How many rows are above this when it is ORDER BY id DESC?
Bare in mind id may not be contigious and someNum is random.
Code: Select all
CREATE TABLE Example (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
someNum INT UNSIGNED NOT NULL
UNIQUE INDEX(someNum)
);
Code: Select all
SELECT id FROM Example WHERE someNum = x
How many rows are above this when it is ORDER BY id DESC?
Bare in mind id may not be contigious and someNum is random.