sql语句在SQLlog可以执行,但是用Db.find执行会报下面的错误,百度了下好像是嵌套的问题,求解决方法
com.jfinal.plugin.activerecord.ActiveRecordException: java.sql.SQLException: SQL injection violation, syntax error: syntax error, expect RPAREN, actual QUES DIV, pos 115 :
SELECT h,d AS m,COUNT(1) AS c FROM ( SELECT DATE_FORMAT(callAt,'%H') AS h, DATE_FORMAT(callAt,'%i') DIV 30 AS d FROM call_record WHERE receptionPerson=23 AND (callAt BETWEEN '2018-01-16' AND '2018-01-17') ) AS t GROUP BY h,d
问题已经找到解决方法,使用Floor函数代替DIV函数
SELECT h,d AS m,COUNT(1) AS c FROM ( SELECT DATE_FORMAT(callAt,'%H') AS h, FLOOR(DATE_FORMAT(callAt,'%i')/30) AS d FROM call_record WHERE receptionPerson=23 AND (callAt BETWEEN '2018-01-16' AND '2018-01-17') ) AS t GROUP BY h,d
项目:JFinal