我正在用另一个字段更新一个字段,这个字段是datetime(datatype),所以更新时应该少一分钟所以我使用的是DATE_SUB()。但我在SyntaxError: missing ) after argument list
INTERVAL
代码:
for(var k=0;k<grouppedArray[i][j].length;k++){
if(grouppedArray[i][j][k+1]){
db.query('update userRegister set logout= ? where userId = ? and catId = ?', [SUBDATE(grouppedArray[i][j][k+1].login, INTERVAL 1 MINUTE), 1, grouppedArray[i][j][k].userId, grouppedArray[i][j][k].catId], function (err, updatedLogout) {
}
}
}
我在哪里错了?请帮忙
答案 0 :(得分:0)
尝试以下方法:
for(var k=0;k<grouppedArray[i][j].length;k++){
if(grouppedArray[i][j][k+1]){
db.query('update userRegister set logout= SUBDATE(?, INTERVAL 1 MINUTE) where userId = ? and catId = ?', [grouppedArray[i][j][k+1].login, grouppedArray[i][j][k].userId, grouppedArray[i][j][k].catId], function (err, updatedLogout) {
}
}
}
或
for(var k=0;k<grouppedArray[i][j].length;k++){
if(grouppedArray[i][j][k+1]){
db.query('update userRegister set logout= ? - INTERVAL 1 MINUTE where userId = ? and catId = ?', [grouppedArray[i][j][k+1].login, grouppedArray[i][j][k].userId, grouppedArray[i][j][k].catId], function (err, updatedLogout) {
}
}
}