【问题标题】:Node js mysql query result ,can i get just the date without the name?Node js mysql查询结果,我可以只得到没有名字的日期吗?
【发布时间】:2021-02-13 04:12:32
【问题描述】:

我有这个代码


    app.post('/check',urlencodedParser,function (req, res) {
  let sql=`SELECT dbdateentre  FROM reservation WHERE idchambre = ${req.body.room}`;
  let query=db.query(sql,(err,result)=>{
    
      console.log(result);

  })
});

这是 console.log 中的结果 它返回给我这个 [ RowDataPacket { dbdateentre: 2020-12-17T23:00:00.000Z } ]

【问题讨论】:

  • 你能在这里复制粘贴你的代码吗?随着日志输出
  • app.post('/check',urlencodedParser,function (req, res) { //pour creer une format de date dateFormat.masks.hammerTime = 'd'; var dateentree=req.body .dateentry; var format=dateFormat(dateentree, "hammerTime"); let sql=SELECT dbdateentre FROM reservation WHERE idchambre = ${req.body.room}; let query=db.query(sql,(err,result)=>{ console.log(result); }) }) ; app.listen('3000',()=>{ console.log('服务器启动了一个端口 3000') });
  • 不错。您可以编辑您的帖子并将其插入其中吗?
  • 我是stackoverflow的新手,我试试
  • 如果你点击“我有这个代码”你可以得到它

标签: mysql node.js


【解决方案1】:

如果你确定你的退货只有一行,你可以试试这个代码

console.log(result[0].dbdateentre)

【讨论】:

  • thannnnnk youuuuuuuuu so mucccch 它成功了!!!!!!!!!!!!
  • 现在我有很多行我怎么能把它们都退回来?
猜你喜欢
  • 2020-05-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-20
  • 1970-01-01
  • 2022-11-10
  • 1970-01-01
相关资源
最近更新 更多