This article will be looking into how to skip the first 10 results from a query result and return the remaining rows using different ways.
Table of Contents:
- Skip first 10 results from MYSQL query using id key
- Skip first 10 results from MYSQL query using subquery
- Skip first 10 results from MYSQL query using LIMIT and OFFSET
Let us get started by preparing the sample data. We will be creating a table, sale_details, followed by inserting rows into it.
#create the table sale_details CREATE TABLE sale_details ( id INT , sale_person_id VARCHAR(255) , sale_person_name VARCHAR(255), no_products_sold INT, sales_department VARCHAR(255) ); # insert rows to sale_details INSERT INTO sale_details (id,sale_person_id,sale_person_name,no_products_sold,sales_department) VALUES(1,"sd1","Henry",2000,"Kitchen Essentials"), (2,"sd1","Henry",5000,"Apparels"), (3,"sd1","Henry",40,"Medicines"), (4,"sd2","Richa",3000,"Kitchen Essentials"), (5,"sd2","Richa",500,"Apparels"), (6,"sd2","Richa",50,"Medicines"), (7,"sd3","Ved",100,"Kitchen Essentials"), (8,"sd3","Ved",150,"Apparels"), (9,"sd3","Ved",1000,"Medicines"), (10,"sd4","George",600,"Kitchen Essentials"), (11,"sd4","George",1200,"Apparels"), (12,"sd4","George",200,"Medicines"), (13,"sd5","Alexendra",487,"Kitchen Essentials"), (14,"sd5","Alexendra",570,"Apparels"), (15,"sd5","Alexendra",510,"Medicines"), (16,"sd6","Gustav",3000,"Kitchen Essentials"), (17,"sd6","Gustav",100,"Apparels"), (18,"sd6","Gustav",150,"Medicines");
Action Output:-

Create table and inserts are successful, to view the snapshot of the table execute:
SELECT * FROM TABLE sale_details;
Output:-

The table sale_details has 18 rows.
Frequently Asked:
Skip first 10 results from MYSQL query using id key
The below query gets only those results that have an id value greater than 10.
SELECT * FROM sale_details WHERE id >10;
Output:-

Skip first 10 results from MYSQL query using subquery
The below query gets only the results, excluding the id values returned by the subquery result.
SELECT * FROM sale_details WHERE ID NOT IN (select id FROM sale_details WHERE id BETWEEN 1 and 10);
Output:-

Skip first 10 results from MYSQL query using LIMIT and OFFSET
The LIMIT clause in MySQL is used to get the limited number of rows in the SELECT query results. OFFSET is passed as a numeric argument that specifies the offset of the first row to return.
Read in details about: LIMIT with OFFSET in MYSQL
The below query will skip the first 10 rows as the OFFSET value passed with the LIMIT clause is 10. This offset skips the specified number of table records. Note that the LIMIT value passed is 10 as well. That will return only 10 records at a time as a query result.
SELECT * FROM sale_details LIMIT 10, 10;
Output:-

The output in image_5 shows 8 rows as there are only 18 rows in the table.
If we do not want to apply any LIMIT to the results, we will have to specify the maximum value of unsigned BIGINT (18446744073709551615) as the limit argument (limit argument is mandatory). Observe the below query.
SELECT * FROM sale_details LIMIT 18446744073709551615 OFFSET 10;
Output:-

READ MORE:
- 4 ways to get last inserted id of a MySQL table
- Find all tables with specific column names in MySQL
- MySQL add primary key multiple columns
- Mysql update set multiple columns
- Mysql update column with value from another table
- Select all columns except one of a MySQL table
- MySQL ADD COLUMN IF NOT EXISTS
- MYSQL: change column order
- MySQL: change column type to VARCHAR without losing data
- MySQL get column names
We hope this article helped you with how to skip first 10 results from the MySQL query. Good Luck!!!