Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
325 views
in Technique[技术] by (71.8m points)

mysql 插入当前时间now()失败

//?新增班级
router.post('/class/add',common.jsonParser,(req, res) => {
 let sql = `INSERT?INTO?class(class_id,class_name,createTime)?VALUES?('SHS10086','${req.body.className}','now()')`;
 db.Query(sql).then(data=>{
  res.send({
   code:200,
   msg:"操作成功"
  });
  res.end();
 })
})

createTime我写死“2020-09-12”就成功,写成now()就插入失败 这是什么原因啊?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

now() 外面的去掉单引号


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...