Home >Database >Mysql Tutorial >How Can I Achieve the Functionality of SQL Server's TOP Keyword in MySQL?
Alternative to MySQL's TOP Keyword
As a user familiar with SQL Server, you may have encountered the TOP keyword, which allows you to retrieve a specified number of top rows from a table based on a specific ordering. However, MySQL does not offer a direct equivalent to TOP.
Instead, MySQL uses the combination of LIMIT and ORDER BY clauses to achieve similar functionality. Here's how you can use them:
SELECT field1, field2 FROM myTable ORDER BY field1 ASC LIMIT 10
Explanation:
The above is the detailed content of How Can I Achieve the Functionality of SQL Server's TOP Keyword in MySQL?. For more information, please follow other related articles on the PHP Chinese website!