mysql - Node.js mysql 选择时间变量

标签 mysql node.js select time

var query = "select * from ? where info = 1;"
var params = [table];  //table = 'light'
connection.query(query, params, function(err, rows) { //this rows returns 'undefined'
        console.log(rows);
        var sql = "UPDATE ? SET info = ?,off_time = '?',run_time = '?' WHERE info = '1'";
        var run_time = time_cal(formatted, rows);
        var params = [table, data, formatted, run_time];
            connection.query(sql, params, function(err, rows) {
          if (err) {
            console.log(err);
          } else {
            console.log("update success!");
          }
        });
      });

mysql表如下

栏目|类型

--------------------------------------+

信息| tinyint(1) ......//1

--------------------------------------+

准时 |时间........//10:00:00

--------------------------------------+

关闭时间 |时间........//11:00:00

--------------------------------------+

运行时|时间........//01:00:00

--------------------------------------+

通过nodejs选择时间变量时,行返回“未定义”

如何接收正确的数据?

最佳答案

可能是因为参数绑定(bind)中表名和列名不能被参数替换。

关于mysql - Node.js mysql 选择时间变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52217789/

相关文章:

mysql - 如何在 MySQL 中强制执行两个相似字段的唯一组合

php - json_encode 将数组转为对象

php - 如何从字符串中删除多段字符? PHP

node.js - 如何从移动服务中 "wake-up"Azure webjob?

sql - PostgreSQL:如何使用包含时间戳的字符列

mysql - 删除MySQL表中的所有重复行(除了1,所有重复行)

node.js - module.exports=require ('other' ) 和临时变量有什么区别?

node.js - graphql-tag/index 没有导出成员 'gql'

python sqlite SELECT 将 AND 与 OR 结合

sql - 如何从表中选择所有列以及 ROWNUM 等其他列?