在SQLite的查询使用LIMIT声明声明、SQLite、LIMIT

2023-09-12 00:33:20 作者:速恋

我有选择的的ListView 行,而不具有限制的查询。但现在,我已经实现了一个共享preferences 用户可以选择多少行将会显示在的ListView ,我SQLite的查询不起作用。我是路过的说法是这样的:

 返回wDb.query(TABELANOME,新的String [] {IDTIT,TAREFATIT,SUMARIOTIT},CONCLUIDOTIT += 1,NULL,NULL,NULL,NULL,LIMIT =' + LIMITE +');
 

解决方案

在等号(= )运算符不符合限制条款。将其删除。

下面是一个例子限制查询:

 从表顺序列BY somethingelse LIMIT 5,10
 
如何提交加计抵减声明 操作指南来了

或者

 从表顺序列BY somethingelse LIMIT 10
 

在你的情况下,正确的说法应该是:

 返回wDb.query(TABELANOME,新的String [] {IDTIT,TAREFATIT,SUMARIOTIT},CONCLUIDOTIT += 1,NULL,NULL,NULL,NULL,将String.valueOf( LIMITE));
 

看看在这里的SQLite的选择语法: http://www.sqlite.org/syntaxdiagrams.html#select-stmt

这形象是相当有用: http://www.sqlite.org/images/syntax/select-stmt.gif

I have a query that selects rows in a ListView without having a limit. But now that I have implemented a SharedPreferences that the user can select how much rows will be displayed in the ListView, my SQLite query doesn't work. I'm passing the argument this way:

return wDb.query(TABELANOME, new String[] {IDTIT, TAREFATIT, SUMARIOTIT}, CONCLUIDOTIT + "=1", null, null, null, null, "LIMIT='" + limite + "'");

解决方案

The equals (=) operator is not used with the LIMIT clause. Remove it.

Here's an example LIMIT query:

SELECT column FROM table ORDER BY somethingelse LIMIT 5, 10

Or:

SELECT column FROM table ORDER BY somethingelse LIMIT 10

In your case, the correct statement would be:

return wDb.query(TABELANOME, new String[] {IDTIT, TAREFATIT, SUMARIOTIT}, CONCLUIDOTIT + "=1", null, null, null, null, String.valueOf(limite));

Take a look here at the SQLite select syntax: http://www.sqlite.org/syntaxdiagrams.html#select-stmt

This image is rather useful: http://www.sqlite.org/images/syntax/select-stmt.gif