"LIMIT 5,10" returns 9 rows in MySQL?

http://666kb.com/i/c6e4rv80gz9yrn9h5.png

Check out my image, I limited the query for just 5 entry but it returns with 9 rows? What is the problem, I could not get it.

Answers


With mysql, the LIMIT parameters are offset, row_count, but the first parameter is optional - crazy, but true!

So when you have two parameters, the first is the starting row, the second is the number of rows.

You asked for LIMIT 5, 10 which means 10 rows, starting from row 5 (not rows 5 to 10).

You are not the first, and you won't be the last, person to be confused by this.


In MySQL Limit function Syntax are:

SELECT column_name(s)
FROM table_name
LIMIT Rows start , Quantity of Rows for display;

Example:

SELECT *
FROM customer
LIMIT 2 , 10;

I suggest go to this link LIMIT in mysql, after I browsed through the above comments, I have to point out, that limit 5, 10 returns 10 rows and it starts from row 6. LIMIT: limit 10 offset 5 and limit 5, 10, both of them return 10 rows, starting from row 6. I strongly recommend go to the above link. Hope it helps!!


Need Your Help

There is no tracking information for the current branch

git github git-pull

I've been using github from a relatively short period, and I've always used the client to perform commits and pulls. I decided to try it from the git bash yesterday, and I successfully created a ne...