3 ways to skip first 10 results

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:

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"),
 (4,"sd2","Richa",3000,"Kitchen Essentials"),
 (7,"sd3","Ved",100,"Kitchen Essentials"),
 (10,"sd4","George",600,"Kitchen Essentials"),
  (13,"sd5","Alexendra",487,"Kitchen Essentials"),
 (16,"sd6","Gustav",3000,"Kitchen Essentials"),

Action Output:-


Create table and inserts are successful, to view the snapshot of the table execute:

SELECT * FROM TABLE sale_details; 



The table sale_details has 18 rows.

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;



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);



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;



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;




We hope this article helped you with how to skip first 10 results from the MySQL query. Good Luck!!!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top