Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

SQLite Limit Query ignor the starting row number



  • Im trying to fetch rows with the LIMIT clause . but what im getting is all the rows untill the limit for example if i execute :
    (this is in the QSqlQueryModel )

    @QString queryFullTextSearch = "SELECT * FROM my_table LIMIT 20,40";
    QSqlQueryModel::setQuery(queryFullTextSearch, queryDB);
    @

    what im getting is the rows from 0 to 40. and if next im executing it from 40 to 80
    what im getting is the rows from 0 to 80.
    is there a problem in the way im executing the query?



  • Your SQL query is wrong. I suggest reading the last paragraphs of http://www.sqlite.org/lang_select.html and use the following statement:

    @
    SELECT * FROM my_table LIMIT 20 OFFSET 20
    SELECT * FROM my_table LIMIT 20 OFFSET 40
    @



  • Thanks very much for your answer !


Log in to reply