Home >Database >Mysql Tutorial >What are the ANSI SQL Alternatives to MySQL\'s LIMIT Keyword?
ANSI SQL Alternatives to the MYSQL LIMIT Keyword
What is the MYSQL LIMIT Keyword and How Does it Work?
The LIMIT keyword in MYSQL allows you to limit the number of rows returned by a SELECT statement. For example, the following query returns the first two rows from the "People" table where the "Age" column is greater than 18:
SELECT * FROM People WHERE Age > 18 LIMIT 2;
The LIMIT clause can also be used to skip a certain number of rows antes de returnar los resultados. For instance, the following query returns the two rows after the first 10 rows from the "People" table where the "Age" column is greater than 18:
SELECT * FROM People WHERE Age > 18 LIMIT 10, 2;
ANSI SQL Alternatives to the LIMIT Keyword
While the LIMIT keyword is a convenient feature in MYSQL, there is no ANSI SQL standard equivalent. However, there are several alternative approaches you can use depending on the database you are working with:
Here is an example of how to use the ROWNUMclause in Oracle to achieve the same result as the LIMIT clause in MYSQL:
SELECT * FROM ( SELECT * FROM People ) WHERE ROWNUM <= 10
The above is the detailed content of What are the ANSI SQL Alternatives to MySQL\'s LIMIT Keyword?. For more information, please follow other related articles on the PHP Chinese website!