we can select row from index i to j with below code in Sql server.how to do it in mysql?
select * from
(SELECT ROW_NUMBER() OVER (ORDER BY FieldName asc) as row,
* from TableName)
WHERE row between STARTINDEX AND ENDINDEX
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m not sure did I understand question totally correct, because I’m not super-familiar with SQL: You want to order results by FieldName and select some portion of results based on row numbers you created. I would write that in MySQL like this:
In MySQL LIMIT index starts from zero (in your SQL-code from 1) and other number in LIMIT clause is number of records you are willing to get
EDIT: My result was missing row number. In case you want row number in your result, it would go like this:
STARTINDEX is same as first row’s number because SELECT will add one to @NUM even at the first time