Can you return the position of the row in comparison to the previous search. For example if I did a simple query: select * from table where name='aa'
it would return
+--+----+---+
|id|name|cid|
+--+----+---+
| 1| aa| 2|
| 5| aa| 2|
| 8| aa| 2|
| 9| aa| 2|
|10| aa| 2|
+--+----+---+
If I changed that query to:
select * from table where name='aa' and id='5'
it would return
+--+----+---+
|id|name|cid|
+--+----+---+
| 5| aa| 2|
+--+----+---+
now according to the first search for where name='aa'
there are 5 rows with and id='5'
being the second row.
So, is there a way to get the position of the row in comparison to initial set? I'd like to be able to print "Result 2 of 5". I can get the number 5
by counting the total rows. I just need to get the position of the and id='5'
. Which I know is the second row of the initial set but I can't seem to figure out a way to return that information. Forgive me if I'm not explaining this properly as I don't quite know how to ask this question.