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?
我在MS Access 2007中创建了一些查询。如果我在查询中使用LIMIT,它们会出错。任何人都可以帮助我吗?如何在MS Access 2007查询中使用LIMIT?
1 个解决方案
#1
18
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:
Access中没有LIMIT关键字(如果使用JET引擎)。您可以使用TOP x给出前x个结果。用法:
SELECT TOP 5 id FROM users ORDER BY joindate
From Microsoft Jet Database Engine Programmer's Guide - Chapter 4:
从Microsoft Jet数据库引擎程序员指南 - 第4章:
TOP N and TOP N PERCENT Predicates
TOP N和TOP N PERCENT预测
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.
虽然您可以使用WHERE和HAVING子句来过滤记录的选择,但有时这还不够。例如,您可能希望选择状态为CA的所有记录,但只能查看前10个客户的订单。 Microsoft Jet提供TOP N和TOP N PERCENT谓词,以限制记录选择后的显示。
TOP N Predicate
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:
您可以使用TOP N谓词指定您的查询仅向程序返回特定数量的记录:
#1
18
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:
Access中没有LIMIT关键字(如果使用JET引擎)。您可以使用TOP x给出前x个结果。用法:
SELECT TOP 5 id FROM users ORDER BY joindate
From Microsoft Jet Database Engine Programmer's Guide - Chapter 4:
从Microsoft Jet数据库引擎程序员指南 - 第4章:
TOP N and TOP N PERCENT Predicates
TOP N和TOP N PERCENT预测
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.
虽然您可以使用WHERE和HAVING子句来过滤记录的选择,但有时这还不够。例如,您可能希望选择状态为CA的所有记录,但只能查看前10个客户的订单。 Microsoft Jet提供TOP N和TOP N PERCENT谓词,以限制记录选择后的显示。
TOP N Predicate
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:
您可以使用TOP N谓词指定您的查询仅向程序返回特定数量的记录: