2

我正在使用 Derby 数据库,并且正在尝试更新我的一个表中的每一列。

我正在使用以下语句:

String stmt = "UPDATE APP.DATAVAULT SET DID = ?, DTITLE = ?, DUNAME = ?, DPASS = ?, DSANSWER = ?, DPIN = ?, DURL = ?, DNOTES = ?, PID = ? WHERE DID = ?, DTITLE = ?, DUNAME = ?, DPASS = ?, DSANSWER = ?, DPIN = ?, DURL = ?, DNOTES = ?, PID = ?";

我之前使用以下语句进行了更新:

String stmt = "UPDATE APP.PERSON SET PSNAME = ? WHERE PID = ?";

有没有更简单的方法来更新整个表?如果不是,我在此声明中做错了什么,因为我不断收到以下错误:

Syntax error: Encountered "," at line 1, column 137.
4

3 回答 3

6

WHERE DID = ?, DTITLE = ?, DUNAME = ?, DPASS = ?, DSANSWER = ?, DPIN = ?, DURL = ?, DNOTES = ?, PID = ?

应该是这个

WHERE DID = ? AND DTITLE = ? AND DUNAME = ? AND DPASS = ? AND DSANSWER = ? AND DPIN = ? AND DURL = ? AND DNOTES = ? AND PID = ?

所以替换,AND.

于 2013-03-29T17:42:24.297 回答
4

应该添加多个子句,ANDnot with comma(,)。一定是WHERE DID = ? AND DTITLE = ? AND...

于 2013-03-29T17:43:26.303 回答
2

WHERE 子句中的逗号应该是 AND

String stmt = "UPDATE APP.DATAVAULT SET DID = ?, DTITLE = ?, DUNAME = ?, DPASS = ?, DSANSWER = ?, DPIN = ?, DURL = ?, DNOTES = ?, PID = ? WHERE DID = ? AND DTITLE = ? AND DUNAME = ? AND DPASS = ? AND DSANSWER = ? AND DPIN = ? AND DURL = ? AND DNOTES = ? AND PID = ?";

于 2013-03-29T17:43:42.727 回答