此查询有什么问题,如果我用实际值替换$ 1,$ 2,$ 3,$ 4,$ 5
这是我的代码。
let queryText = "INSERT INTO`calculator_challenge`.`calculations`
(`number1`, `operator`, `number2`, `total`, `created_at`)
VALUES ($1, $2, $3, $4, $5);";
pool.query(queryText, [calc_obj.number1, calc_obj.operator, calc_obj.number2, calc_obj.total, calc_obj.created_at], (error, result, fields) => {
if (error) throw error;
res.send(JSON.stringify(result));
});
});
答案 0 :(得分:0)
按如下所示更新代码:(我加上了一些引号)
let queryText = "INSERT INTO`calculator_challenge`.`calculations`(`number1`, `operator`, `number2`, `total`, `created_at`) VALUES ('$1', '$2', '$3', '$4', '$5')";