我们有一个Interbase 7.1数据库,我正在试图弄清楚如何将查询返回的记录数限制为1.我真的只需要知道最后一条记录中的事件代码,其中查询如果我不能做某种限制,将返回数百条记录。
提前致谢!
答案 0 :(得分:12)
我想我明白了。需要做这样的事情......
SELECT * FROM table ORDER BY col ROWS 1
答案 1 :(得分:5)
根据接受的答案:
SELECT * FROM table ORDER BY col ROWS 1
只返回一个结果。 还有其他几种行限制选项:
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 Product Documentation页面上的嵌入式SQL指南: