SQLite3和限制结果数 [英] SQLite3 and limiting the number of results
问题描述
是否有一种干净的方法来限制SQLite3 SELECT
语句的命中次数?
Is there a clean way to limit the number of hits from an SQLite3 SELECT
statement?
例如,我可能会使用SELECT * FROM myTable WHERE name='Smith';
进行查询,意识到我可能会遇到数千次匹配.我想要SQLite3告诉我它遇到的前10个,然后终止查询.我该怎么做?
For example, I might query with SELECT * FROM myTable WHERE name='Smith';
realising I could encounter thousands of hits. I'd like SQLite3 to give me say the first 10 it encounters and then terminate the query. How do I do this?
如果SQLite3没有立即提供此功能,那么我可以在SQLite3源代码中进行编辑的内容吗?
If SQLite3 does not provide this immediately, is there anything I can edit in the SQLite3 source code from which I can rebuild?
假设我处于一个只有一个线程并且希望在合理的时间内进行控制的环境中.
Assume I'm in an environment where I have only one thread and I'd like control back in a reasonable time.
推荐答案
您正在寻找LIMIT
子句:
SELECT * FROM myTable WHERE name='Smith' LIMIT 10
这篇关于SQLite3和限制结果数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!