这是错误,但我无法确定它。从phpmyadmin SQL控制台
运行时,查询运行fintvar query = connection.query('Select distinct a.*, IFNULL(b.scannerid,'Not Available') AS `scannerid`, IFNULL(date(b.datetime),'Not Available') as datetime, IFNULL(b.status,'Absent') AS `status` from studentdetails a LEFT OUTER JOIN discovereddevices b ON a.bluetoothid = b.blueid and date (b.datetime) = CURRENT_DATE',function(err,rows)
错误:
SyntaxError: missing ) after argument list
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/ubuntu/Attendance system/app.js:13:24)
Javascript代码:
exports.getattendance = function(req, res){
req.getConnection(function(err,connection){
var query = connection.query('Select distinct a.*,
IFNULL(b.scannerid,'Not Available') AS `scannerid`,
IFNULL(date(b.datetime),'Not Available') as datetime,
IFNULL(b.status,'Absent') AS `status` from studentdetails a LEFT OUTER
JOIN discovereddevices b ON a.bluetoothid = b.blueid and date (b.datetime)
= CURRENT_DATE',function(err,rows)
{
if(err)
console.log("Error Selecting : %s ",err );
res.render('showreport',{page_title:"Attendance Report Generated",data:rows});
});
//console.log(query.sql);
});
};
答案 0 :(得分:2)
行情使用错误 尝试使用反引号(`)
示例:
exports.getattendance = function(req, res){
req.getConnection(function(err,connection){
var query = connection.query(`Select distinct a.*, IFNULL(b.scannerid,'Not Available') AS 'scannerid', IFNULL(date(b.datetime),'Not Available') as datetime, IFNULL(b.status,'Absent') AS 'status' from studentdetails a LEFT OUTER JOIN discovereddevices b ON a.bluetoothid = b.blueid and date (b.datetime) = CURRENT_DATE()`,
function(err,rows)
if(err)
console.log("Error Selecting : %s ",err );
res.render('showreport',{page_title:"Attendance Report Generated",data:rows});
});
//console.log(query.sql);
});
};
编辑:
CURRENT_DATE()也应该是一个函数!