Using the LIMIT statement in a SQLite query

前端 未结 3 1987
栀梦
栀梦 2020-11-27 16:38

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

3条回答
  •  渐次进展
    2020-11-27 16:56

    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

提交回复
热议问题