LIMIT in SQL

Video Tutorial
FREE
 LIMIT, OFFSET thumbnail
This video belongs to
DBMS Course - Master the Fundamentals and Advanced Concepts
16 modules
Certificate
Topics Covered

What is Limit Clause in SQL?

A Limit clause is commonly used in SQL when dealing with large datasets to limit the number of records that are returned from the SELECT statement.

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

How to Use the Limit Clause in SQL?

Limit clauses are often used nested inside a SELECT statement, and the only purpose they satisfy is to return the specified number of records only.

The syntax for the same is given below.

The parameter in the above SELECT statement is number_rows, which is the limiting number of rows it is expected to return.

Example of Limit Clause in SQL

Consider the example table below:

IDNameSalary
1Ram50000
2Shyam40000
3Mohan58000
4Kishan10000
5Mahesh23000
6Dinesh45000
7Amit99000
8Jatin87000

Let's say we want the top 6 records to be selected from this table, the limit clause, along with the SELECT statement, will help us achieve it.

The result of the following select statement is given below.

IDNameSalary
1Ram50000
2Shyam40000
3Mohan58000
4Kishan10000
5Mahesh23000
6Dinesh45000

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

What is a Select LIMIT Statement, its Syntax, and Parameter Values?

As the name suggests, a SELECT limit statement is a standard statement with a LIMIT clause added to it, which is aimed at limiting the number of records selected.

The syntax for the same is given below.

The number_rows parameter can have any positive integer value.

What are the Advantages of the LIMIT Clause in SQL?

According to the LIMIT clause, only the maximum number of rows is included in the result collection. No additional rows are returned that satisfy the question collection condition, which saves us time and memory.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data

Learn More

Conclusion

  • LIMIT in SQL is useful for selecting a specific number of rows from the table.
  • It is used inside a SELECT statement.
  • It can also be followed by clauses like ORDER BY which will give the ordered result for a specified number of rows.
Hiring Partners:
GGoogleAAmazonMicrosoftFFlipkartAAdobe1200+ more