If there is a way to query according to row number ? Like:
select rownumber from table;
what i am trying to do:
I have computed the total number of rows in a table using sub queries and now I want to display only the last one.
rookie answer:
I wanted to get the 2nd highest salary. so this is what i did:
select * from gg where salary< (select max(salary) from gg) order by salary desc limit 1
This doesnot work for Nth highest salary its for 2nd highest only. AND I AM NEW TO THIS SO I JUST WANTED TO GET THE 2ND HIGHEST BY MY OWN METHOD.
Although I’m not sure why you would want to get a specific rownumer, you could do it like this:
Read more on this on http://dev.mysql.com/doc/refman/5.0/en/select.html
So if you want the 3rd row you’ll do:
SELECT * FROM table LIMIT 3,1;If you want the 6th-16th row you’ll use:
SELECT * FROM table LIMIT 6,10Do understand that this is only usefull to get a random row or when you add SORT BY. Otherwise you will never be sure what row will be returned…