node.js mysql选择时间变量

wkftcu5l  于 2021-06-20  发布在  Mysql
关注(0)|答案(6)|浏览(428)
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下表
柱式

rsl1atfo

rsl1atfo1#

原因可能是参数绑定中的参数不能替换表名和列名。

zfciruhq

zfciruhq2#

--------+
信息| tinyint(1)………//1

cuxqih21

cuxqih213#

--------+
准时|时间……../10:00:00

vkc1a9a2

vkc1a9a24#

--------+
下班时间|时间……../11:00:00

mwg9r5ms

mwg9r5ms5#

--------+
运行时间|时间……../01:00:00

9fkzdhlc

9fkzdhlc6#

--------+
当nodejs选择时间变量时,行返回“undefined”
如何接收正确的数据?

相关问题