这里会记录自己在Qt5开发中使用SQL语句时遇到的坑点
1. 尽量别换行,有的时候一句SQL换行就执行不了
2. 模糊查询
bindValue
对于下面的代码
// 对id进行模糊查询
sql_qry.prepare("select id from account where id like :id");
sql_qry.bindValue(":id", "%" + key + "%");
在sql中的形式应该为
select id from account where id like '%id%'
这里注意bindValue会自动给你加上一对单引号''
,所以你如果要加上%
来做模糊匹配的话,务必写在bindValue
里面