如何在访问查询中使用LIMIT,但不使用TOP [英] How to use LIMIT in query in access, but not TOP
问题描述
我想显示查询中的15行,但不显示前15行?
I would like to display 15 rows from queries but not first 15?
SELECT Abgänge.Vorgang, Abgänge.Date_SW_Drucken FROM Abgänge
WHERE Abgänge.Bezahlung = "Bar" LIMIT 34,15;
如何将其转换为Access 2010?
How to transform this to access 2010?
限制:
LIMIT from_record-1, count_record
推荐答案
You can't, because there is no support for an offset in the Microsoft Access SELECT
syntax. An option is to use TOP
with offset + limit
and skip offset
rows manually. BTW: Using TOP
or LIMIT
without an ORDER BY
is not advisable as it can lead to inconsistent results.
您还可以将两个查询与TOP
组合在一起,例如,首先选择limit + offset
,然后仅选择offset
You could also combine two queries with TOP
, first selecting limit + offset
, and then selecting only offset
, for example
SELECT TOP 15 ...
FROM (
SELECT TOP 49 ....
FROM sometable
ORDER BY somecolumn ASC
) a
ORDER BY somecolumn DESC
此解决方案的唯一问题是,如果子查询的结果少于49个,则偏移量将小于34.
The only problem with this solution is that if there are less than 49 results from the subquery, then the offset will be less than 34.
如果您需要按不同顺序排列结果,则可能需要添加一个应用该顺序的附加图层".
If you need the result in a different order then you may need to add an additional 'layer' that applies that order.
这篇关于如何在访问查询中使用LIMIT,但不使用TOP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!