我在程序中包含了SQLite和SQLite语句。我有一个名为PILE的表,PILE表有以下列
单词|含义|频率| C1 | C2 | C3 | C4 | C5
tx.executeSql(
"UPDATE PILE SET ? = COALESCE( (SELECT ? FROM PILE WHERE word = ?), 0 ) -1 WHERE word = ?",
[category1, category1, incorrectmanualanswer, incorrectmanualanswer] ,
errorcode );
alert("down "+category1+"+"+incorrectmanualanswer);
以上不执行。我确实在以下警告窗口中看到了正确的值
但是下面的表现完全
function screenONEpress(tx)
{
tx.executeSql(
"UPDATE PILE SET frequency = COALESCE( (SELECT frequency FROM PILE WHERE word = ?), 0 ) + 1
WHERE word = ?", [newEword, newEword] , errorcode );
}
答案 0 :(得分:1)
参数插值引用并转义在sql语句中使用的参数,并且不会将单词插入到sql代码中。所以生成的sql看起来像UPDATE PILE SET 'category1' = COALESCE( ...
,这是一个语法错误。