以下命令适用于sqlite browser,不确定为什么Qt5.11.2会失败
using namespace edatabase;
QSqlQuery query;
QString const command("with ab as (select a.* from recorded_face_whitelist_log a union all select "
"b.* from recorded_face_log b)SELECT ID, FaceID, Image FROM "
"(SELECT ab.*,ROW_NUMBER() OVER (PARTITION BY FaceID ORDER BY DATE DESC, TIME DESC) "
"as seqnum FROM ab) ab WHERE seqnum = 1 ORDER BY Date DESC, Time DESC LIMIT 5");
//query.prepare(command);
query.exec(command);
if(!query.lastError().isValid()){
//do something
}else{
QLOG_DEBUG()<<__func__<<query.lastError()<<"\ncommand:"<<command;
}
}
错误消息:
QSqlError(“ 1”,“无法执行语句”,“靠近”(“:语法错误”)
我该如何解决此错误?谢谢
编辑:我将QLOG_DEBUG打印的命令复制到sqlite浏览器,它可以正常工作。该命令没有任何特殊字符,所以我不需要任何“ \”,很奇怪。