Limitoffset and n reveal the secrets of using limit offset today. when n exports data from a table in batches, there are several fewer records than the original table. only when a small table is created for test can we find the secrets:
mysql> select * from sss1;
+----+------+------+
| id | name | c_id |
+----+------+------+
| 1 | aaa | 1 |
| 2 | bbb | 2 |
| 3 | ccc | 3 |
| 4 | ddd | 1 |
| 5 | eee | 4 |
| 6 | ffff | 6 |
| 7 | NULL | 0 |
| 8 | NULL | 0 |
| 9 | NULL | 0 |
| 10 | ssss | 0 |
| 11 | ooo | 0 |
| 12 | 234 | 0 |
+----+------+------+
12 rows in set (0.00 sec)
mysql> select * from sss1 limit 0,3;
+----+------+------+
| id | name | c_id |
+----+------+------+
| 1 | aaa | 1 |
| 2 | bbb | 2 |
| 3 | ccc | 3 |
+----+------+------+
3 rows in set (0.00 sec)
mysql> select * from sss1 limit 4,6;
+----+------+------+
| id | name | c_id |
+----+------+------+
| 5 | eee | 4 |
| 6 | ffff | 6 |
| 7 | NULL | 0 |
| 8 | NULL | 0 |
| 9 | NULL | 0 |
| 10 | ssss | 0 |
+----+------+------+
6 rows in set (0.00 sec)
Do you understand?
If there is offset, it will be displayed from offset + 1, beyond the offset, so I will only have a few fewer records after batch, which is just my offset point, solution: The offset value is the same as the n value in the previous step:
mysql> select * from sss1;
+----+------+------+
| id | name | c_id |
+----+------+------+
| 1 | aaa | 1 |
| 2 | bbb | 2 |
| 3 | ccc | 3 |
| 4 | ddd | 1 |
| 5 | eee | 4 |
| 6 | ffff | 6 |
| 7 | NULL | 0 |
| 8 | NULL | 0 |
| 9 | NULL | 0 |
| 10 | ssss | 0 |
| 11 | ooo | 0 |
| 12 | 234 | 0 |
+----+------+------+
12 rows in set (0.00 sec)
mysql> select * from sss1 limit 0,3;
+----+------+------+
| id | name | c_id |
+----+------+------+
| 1 | aaa | 1 |
| 2 | bbb | 2 |
| 3 | ccc | 3 |
+----+------+------+
3 rows in set (0.00 sec)
mysql> select * from sss1 limit 3,6;
+----+------+------+
| id | name | c_id |
+----+------+------+
| 4 | ddd | 1 |
| 5 | eee | 4 |
| 6 | ffff | 6 |
| 7 | NULL | 0 |
| 8 | NULL | 0 |
| 9 | NULL | 0 |
+----+------+------+
6 rows in set (0.00 sec)