本文介绍了我在DELETE语句中有一个SQLite语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个非常奇怪的sqlite语法错误.
const char * statement =从引号t1删除,其中t1.id = 127";int returnCode = sqlite3_exec(数据库,语句,NULL,NULL,& errorMsg);如果(returnCode!= SQLITE_OK){fprintf(stderr,错误:%s",errorMsg);sqlite3_free(errorMsg);}错误:"t1"附近:语法错误
但是这段代码很好用
const char * statement =从引号WHERE id = 127处删除";int returnCode = sqlite3_exec(数据库,语句,NULL,NULL,& errorMsg);
解决方案
SQLite不允许在delete语句中使用别名.
有关允许的语法,请参见
I have a very strange sqlite syntax error.
const char *statement = "DELETE FROM quotes t1 WHERE t1.id=127";
int returnCode = sqlite3_exec(database, statement, NULL, NULL, &errorMsg);
if (returnCode!=SQLITE_OK)
{
fprintf(stderr, "Error: %s", errorMsg);
sqlite3_free(errorMsg);
}
Error: near "t1": syntax error
But this code works well
const char *statement = "DELETE FROM quotes WHERE id=127";
int returnCode = sqlite3_exec(database, statement, NULL, NULL, &errorMsg);
解决方案
SQLite doesn't allow aliases in delete statements.
See the manual for the allowed syntax.
这篇关于我在DELETE语句中有一个SQLite语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!