LIMIT Phrase SQL

The LIMIT Phrase is useful to limit the number of items returned from a query. It normally occurs at the end of a SELECT Statement in the following manner:

SELECT columns
FROM table
WHERE column = 'data'
LIMIT first_row, number_of_rows

If only one parameter for limit is entered, the query will simply respond with the number of rows.

For example, in our monopoly_prop table we have the following:

idstreet_namecolor
1Connecticut Avelt blue
2St. James Placeorange
3Kentucky Avered
4Board Walkblue

We want to know the second and third properties we purchased. We can make the following query remembering that the first row will be 0:

SELECT street_name FROM monopoly_prop LIMIT 1, 2

The result will be:

street_name
St. James Place
Kentucky Ave.

This phrase was developed for mySQL. May not work in some other applications.

< LIKE Operator SQL | NULL >


Send notes in disappearing ink!

Interesting Pages