# QT SQLite3分页删除问题

## terminal实验

sqlite> select * from test;
1|10
2|20
3|30
sqlite> select * from test order by var2 desc;
3|30
2|20
1|10
sqlite> select * from test order by var2 desc limit 2 offset 2;
1|10
sqlite> select * from test order by var2 desc limit 2 offset 0;
3|30
2|20

sqlite> delete from test limit 1;
sqlite> select * from test;
2|20
3|30

sqlite> select * from test2;
hello|123124
abcse|223124
abc|323124
sqlite> delete from test2 order by num asc limit 1;
sqlite> select * from test2;
abcse|223124
abc|323124

## QT下SQlite分页删除

CREATE TABLE IF NOT EXISTS Vocabulary (myWord text, translation text, secs INTEGER, PRIMARY KEY(myWord, secs))

SQL语句为 DELETE FROM Vocabulary ORDER BY secs ASC LIMIT :limitNumber

QT将:limitNumber当作数据表的字段了。

Optional LIMIT and ORDER BY clauses:

If SQLite is compiled with the SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile-time option, then the syntax of the DELETE statement is extended by the addition of optional ORDER BY and LIMIT clause SQLITE_ENABLE_UPDATE_DELETE_LIMIT

This option enables an optional ORDER BY and LIMIT clause on UPDATE and DELETE statements.

If this option is defined, then it must also be defined when using the Lemon parser generator tool to generate a parse.c file. Because of this, this option may only be used when the library is built from source, not from the amalgamation or from the collection of pre-packaged C files provided for non-Unix like platforms on the website.


• 评论

• 上一篇
• 下一篇