我在DELETE语句中有一个SQLite语法错误

时间:2012-07-22 15:34:28

标签: macos sqlite

我有一个非常奇怪的sqlite语法错误。

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

但是这段代码效果很好

const char *statement = "DELETE FROM quotes WHERE id=127";
int returnCode = sqlite3_exec(database, statement, NULL, NULL, &errorMsg);

1 个答案:

答案 0 :(得分:5)

SQLite不允许删除语句中的别名。

请参阅manual了解允许的语法。


delete-stmt

enter image description here

qualified-table-name

enter image description here