Mysql 错误:ER_PARSE_错误:您的SQL语法有错误;日期时间
代码通过向行中添加其他用户Id来更新用户, 当我向这个函数传递一个满足我得到的值的对象时Mysql 错误:ER_PARSE_错误:您的SQL语法有错误;日期时间,mysql,node.js,Mysql,Node.js,代码通过向行中添加其他用户Id来更新用户, 当我向这个函数传递一个满足我得到的值的对象时 async addToPlayerGame(queueItem) { // update the row with the userId and start round1 this.gameState = process.env.GAME_ROUND1; let sql = `UPDATE gamequeue SET secondPlayer=${ this.first
async addToPlayerGame(queueItem) {
// update the row with the userId and start round1
this.gameState = process.env.GAME_ROUND1;
let sql = `UPDATE gamequeue SET secondPlayer=${
this.firstPlayer
}, gameState=${this.gameState}
WHERE firstPlayer=${queueItem.firstPlayer} AND secondPlayer=${
queueItem.secondPlayer
} AND createdAt=${new Date(queueItem.createdAt)} AND playerType=${
queueItem.playerType
}`;
return await query(sql);
}
async function query(sql) {
try {
result = await db.query(sql);
return { err: null, result: result };
} catch (error) {
return { err: error.toString(), result: null };
}
}
但对于这一点,我得到了这个错误
"Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Jul 13 2020 17:42:49 GMT+0530 (India Standard Time) AND playerType=1' at line 2"