On the web I see a lot of questions of developers who are wanting to know how they can retrieve only the first N records in their queries.
The answer is simple, LIMIT
For example, if you only want to select the top 5 names from a names tables, use the following query:
SELECT `firstname`,`lastname` FROM `names` ORDER BY `firstname` LIMIT 0,5
This query will return only the first 5 names from the names table.
If you want to select the first 10, use the following query:
SELECT `firstname`,`lastname` FROM `names` ORDER BY `firstname` LIMIT 0,10
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.