how to use LIMIT in query of MS ACCESS 2007 how to use LIMIT in query of MS ACCESS 2007 database database

how to use LIMIT in query of MS ACCESS 2007


There is no LIMIT keyword in Access (if you use the JET engine). You can use TOP x to give the first x results.Usage:

SELECT TOP 5 id FROM users ORDER BY joindate

From Microsoft Jet Database Engine Programmer's Guide - Chapter 4:

TOP N and TOP N PERCENT Predicates

Although you can use the WHERE and HAVING clauses to filter the selection of records, sometimes this isn't sufficient. For example, you may want to select all records where the state is CA, but only see the orders for the top 10 customers. Microsoft Jet provides TOP N and TOP N PERCENT predicates to limit the presentation of records after they're selected.

TOP N Predicate

You can use the TOP N predicate to specify that your query return only a specific number of records to your program: