如何限制为Interbase 7.1返回的记录数?

Dra*_*821 5 sql interbase limit

我们有一个Interbase 7.1数据库,我正在试图弄清楚如何将查询返回的记录数限制为1.我真的只需要知道上一条记录中的事件代码,其中查询将返回数百条记录,如果我不能做某种限制.

提前致谢!

Dra*_*821 12

我想我明白了.需要做这样的事......

SELECT * FROM table ORDER BY col ROWS 1
Run Code Online (Sandbox Code Playgroud)


abo*_*021 5

根据公认的答案:

SELECT * FROM table ORDER BY col ROWS 1
Run Code Online (Sandbox Code Playgroud)

只返回一个结果.还有其他几种行限制选项:

ROWS n        Returns the first n rows of the result set, or n percent if used with PERCENT
ROWS m TO n   Returns rows m through n, inclusive or the mth to nth percent
ROWS n BY p   Returns every pth row of the first n rows

这对于分页结果尤其方便.

InterBase产品文档页面上的嵌入式SQL指南: