Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use LIMIT in query of MS ACCESS 2007

I have created some queries in MS Access 2007. they are giving error if I use LIMIT in query. Can anyone help me out in this? How to use LIMIT in MS Access 2007 query?

like image 330
gautamlakum Avatar asked May 24 '11 08:05

gautamlakum


People also ask

Is there a limit to the number of fields in an Access query?

Was this reply helpful? There is a limit - but it's 255 fields. The Grid is not the query, it's just a (somewhat quirky and limited) tool to build queries. Scott described how to add more columns in the grid; you can also switch the query to SQL view and edit the REAL query.


1 Answers

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:

like image 160
Jacob Avatar answered Sep 19 '22 18:09

Jacob