我有一个问题。请看一下我的脚本:
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
放入查询中。正确的脚本如何执行此操作?
最佳答案
将引号从 '
更改为 "
。
或者您可以更改 configuration在 SQL 中
关于javascript - Nodejs-Mysql : "SyntaxError: Unexpected end of input" if Query Contains 'WHERE' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34259942/