how to know the row number in sql table ?

0 Montaser Qasem · January 19, 2015
Hello guys, i'v been recently trying to execute a query to define the number of the row which i work with such as:


Table name:Employee
  id   name  salary
   5   john     1000$
   7   bucky   1500$
   10 alex      500$
   9   tuna      600$



in this case employee john has the row number 1 and bucky number 2
so how i can know this in sql query ?
i searched on google and all said that use function called NUMBER_ROW()  and i tried to use it but it keeps telling me that is does not exist at all so any help to me on order to know how i work with that Guys ? :)

Post a Reply

Replies

Oldest  Newest  Rating
0 Montaser Qasem · January 19, 2015
Branislav Lazic
Thank you man :) you solved my problem , i didn't know the offset untill now thank you:D
+1 Branislav Lazic · January 19, 2015
And what for you need primary keys then? Pagination can be done in much different way.
Like: 


SELECT * FROM Employee ORDER BY id DESC LIMIT 10 OFFSET 0;




That will fetch last 10 records.

Increase OFFSET for every new page. Size is 10. 
0 Montaser Qasem · January 19, 2015
i'm making a pagination buttons in my website to get an oledst posts or comments etc like that so i want this query to help me out of it :)
  • 1

SQL & Databases

107,133 followers
About

Everything SQL and Databases related in here!

Links
Moderators
Bucky Roberts Administrator