2009-06-24 62 views
5

我們有一個Interbase 7.1數據庫,我試圖弄清楚如何將查詢返回的記錄數限制爲1.我真的只需要知道最後一條記錄中的事件代碼,其中查詢將會如果我不能做某種限制,會返回數百條記錄。如何限制爲Interbase 7.1返回的記錄數量?

在此先感謝!

回答

11

我想我想通了。需要做這樣的事情...

SELECT * FROM表ORDER BY山坳出行1

4

按照接受的答案:

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指南頁面:

相關問題