Mybatis报错:sql injection violation, syntax error: syntax error, expect RPAREN, actual FOR FOR
sql语句放在navicate中可以正常执行,但是在MyBatis中则报上述错误,sql语句如下:
SELECT
SUBSTR( a.date FROM 6 FOR 7 ) AS date,
a.consumption
FROM
(
SELECT
DATE_FORMAT( date( e.COLLECT_TIME ), '%Y-%m' ) AS date,
sum( e.PAP_R_I ) AS consumption
FROM
ec_electric_value e
WHERE
1 = 1
AND YEAR ( e.COLLECT_TIME ) = YEAR ( now( ) )
GROUP BY
date
) a
报错的是【SUBSTR】方法,即SUBSTR(XX FROM pos FOR len),MyBatis不支持这种写法,所以改成SUBSTR(XX, pos, len)即可,问题解决。
Mybatis报错:sql injection violation, syntax error: syntax error, expect RPAREN, actual FOR FOR最先出现在Python成神之路。
共有 0 条评论