Nodejs - Mysql : "SyntaxError: Unexpected end of input" if Query Contains 'WHERE'
Nodejs - Mysql : "SyntaxError: Unexpected end of input" if Query Contains 'WHERE'
我有一个问题。请看一下我的脚本:
var dbconn = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '123',
database : 'mydb'
});
var query = dbconn.query("SELECT * FROM m02serials WHERE SerialNumber = '"+serialnumber+"'");
我的 IDE 上没有显示上述脚本的错误提示。但是,在上面一行之后有一条错误消息:
SyntaxError: Unexpected end of input
at Object.exports.createScript (vm.js:24:10)
at REPLServer.defaultEval (repl.js:137:25)
at bound (domain.js:250:14)
at REPLServer.runBound [as eval] (domain.js:263:12)
at REPLServer.<anonymous> (repl.js:393:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:549:8)
at REPLServer.Interface._ttyWrite (readline.js:884:20)
如果我只写SELECT * FROM m02serials
查询(没有WHERE
),就不会出现上面的错误信息。但是,我想将 WHERE
放入查询中。正确的脚本如何执行此操作?
将引号从 '
更改为 "
。
或者您可以更改 SQL
中的 configuration
我有一个问题。请看一下我的脚本:
var dbconn = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '123',
database : 'mydb'
});
var query = dbconn.query("SELECT * FROM m02serials WHERE SerialNumber = '"+serialnumber+"'");
我的 IDE 上没有显示上述脚本的错误提示。但是,在上面一行之后有一条错误消息:
SyntaxError: Unexpected end of input
at Object.exports.createScript (vm.js:24:10)
at REPLServer.defaultEval (repl.js:137:25)
at bound (domain.js:250:14)
at REPLServer.runBound [as eval] (domain.js:263:12)
at REPLServer.<anonymous> (repl.js:393:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:549:8)
at REPLServer.Interface._ttyWrite (readline.js:884:20)
如果我只写SELECT * FROM m02serials
查询(没有WHERE
),就不会出现上面的错误信息。但是,我想将 WHERE
放入查询中。正确的脚本如何执行此操作?
将引号从 '
更改为 "
。
或者您可以更改 SQL
中的 configuration