【发布时间】:2020-08-21 12:03:24
【问题描述】:
调用嵌套查询。我需要在节点 js 的一个 api 调用中调用 2 个查询。我正在使用 npm mysql 库。第一个查询运行,但第二个不运行。如何一个一个地运行两个查询?
router.delete("/:id", async (req, res) => {
conn.query(
"Delete FROM assignedcourses WHERE CourseID = ?",
req.params.id,
async (err, results) => {
if (err) throw err;
conn.query(
"Delete FROM courses WHERE CourseID = ?",
req.params.id,
async (err, results) => {
res.send(results);
}
);
}
);
});
【问题讨论】:
-
会发生什么?你的代码执行结果是什么?错误?!