Limit the Number of Resulting Records
Explore how to use the LIMIT clause in SQL to restrict the number of rows returned by queries. Learn to combine LIMIT with WHERE and ORDER BY to refine your results, such as retrieving the highest or lowest priced products and filtering data more efficiently.
We'll cover the following...
We'll cover the following...
Sometimes, we want to return the first row that matches the select criteria, even if more rows might match. We can do that using the limit at the end of the select statement.
For example, let’s suppose that we want to get the most expensive product in our catalog. This is returned with the following select statement: