SQL LIMIT Clause

By Hemanta Sundaray on 2022-12-04

Most SQL tables contain hundreds of thousands of records. In those situations, it becomes important to cap the number of rows in the result set.

For instance, imagine that we just want to see a few examples of records.

SELECT *
FROM movies
LIMIT 10;

LIMIT is a clause that lets you specify the maximum number of rows the result set will have. This saves space on our screen and makes our queries run faster.

Here, we specify that the result set can’t have more than 10 rows.

Note that LIMIT always goes at the very end of the query. Also, it is not supported in all SQL databases.

Join the Newsletter