query.exec(QString("delete from History where(select count(nowTime) from History) >%1 and nowTime in(select nowTime from History order by nowTime desc limit(select count(nowTime) from History) offset %2)").arg(MAX_HISTORY_CNT).arg(MAX_HISTORY_CNT));
超过 MAX_HISTORY_CNT条的数据 会被删除,从选中表的第1条数据开始删除
好久不写,都忘记这条语句怎么写了,从历史程序中翻出来,特意记录一下,
创建表的代码如下
query.exec(QString("create table History (nowTime varchar(16),idNum int, primary key(nowTime,idNum))"));