mysql - 错误 : ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

标签 mysql node.js node-mysql

我正在尝试使用从 NPM 下载的“mysql”模块将一些数据从 Node JS 发送到 MySQL。

connection.beginTransaction(function(err) {
        if (err) { throw err }
        connection.query(sq, function (error, result) {
              if (error) {
            //return connection.rollback(function() {
            throw err
          //})
          } else {
            console.log('data is inserted ... ' + new Date())
          }
        })

我的查询,即 sq 是类似的东西..

INSERT INTO archlb_sales(fiscalYear, fiscalQuarterID, fiscalPeriodID, fiscalWeekID, geo, theater, area, operation, region, country, salesAgen
tName, emailID, arch, technology, subTechnology, tms3, productFamily, scms, totalSales, agentType, salesAgentnumber, softBookingsNet) values ('
2017', '2017Q1', '201701', '2017014', 'Americas', 'Americas-MISCL2', 'Americas-MISCL3', 'Americas-MISCL4', 'Americas-MISCL5', 'UNKNOWN', 'G2C A
djustment Agent', 'UNKNOWN' , 'Collaboration' , 'Collaboration','CLOUD SW' , 'CLD-AUDIO-SW' , 'CWAU', 'OTHER' , -205, 'TEAM AGENT', 'UNKNOWN' ,
 '1') ON DUPLICATE KEY UPDATE totalSales = totalSales + -205;

INSERT INTO archlb_sales(fiscalYear, fiscalQuarterID, fiscalPeriodID, fiscalWeekID, geo, theater, area, operation, region, country, sal
esAgentName, emailID, arch, technology, subTechnology, tms3, productFamily, scms, totalSales, agentType, salesAgentnumber, softBookingsNet) val
ues ('2017', '2017Q1', '201701', '2017014', 'Americas', 'Americas-MISCL2', 'Americas-MISCL3', 'Americas-MISCL4', 'Americas-MISCL5', 'UNKNOWN',
'G2C Adjustment Agent', 'UNKNOWN' , 'Collaboration' , 'Collaboration','CLOUD SW' , 'CLD-AUDIO-SW' , 'CWAUCC', 'OTHER' , -123, 'TEAM AGENT', 'UN
KNOWN' , '1') ON DUPLICATE KEY UPDATE totalSales = totalSales + -123;

这些变量的值是从文本文件中读取的,它们是正确的

MySQL 给出以下错误。

Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the ri
ght syntax to use near \'INSERT INTO archlb_sales(fiscalYear, fiscalQuarterID, fiscalPeriodID, fiscalWeek\' at line 3

这是表架构:

enter image description here

最佳答案

您试图在一个查询中执行多个 SQL 语句,除非您显式设置 multipleStatements,否则该查询将被禁用选项。

关于mysql - 错误 : ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40503966/

相关文章:

javascript - 如何使用 Node.js 比较文本和图像文件内容是否相等?

Javascript 函数不返回数据 - Node-MySQL

java - 如何修复列索引超出范围 SQLException

mysql - 如果条目在数据库中,则放弃插入操作并删除条目

node.js - io.sockets.socket(socket_id).emit() - 没有方法 'socket'

javascript - Nodejs MySQL 静默失败

node.js - Node mysql 无法离线工作

php/Codeigniter--如何通过排除时间来比较日期

php - 如何为通过 PHP 发送到 android 的 json 数据设置 if 条件

node.js - Socket.io 客户端未与服务器连接