mybatis case when 报错

版权声明:转载请注明出处,谢谢 https://blog.csdn.net/guoqing2016/article/details/89233882

在mybatis中使用case when进行条件筛选判断时遇到

Failed to process, please exclude the tableName or statementId.

这样的报错信息,报错的信息是语法错误
但是我在mysql的命令行中运行sql语句是没问题的

//我的case when语句
WHERE dept.type = 1
AND 
(
CASE agent.dept_type
WHEN "agent" THEN dept.id=30
END
)
//当agent的dept_type为"agent"时,将添加dept.id = 30的判断

这段sql语句在命令行内运行没问题但是放到mybatis上执行就会报错

//修改后
WHERE dept.type = 1
AND dept.id=
(
CASE agent.dept_type
WHEN "agent" THEN 30
END
)

后来将dept.id放到外面就解决了这个问题

猜你喜欢

转载自blog.csdn.net/guoqing2016/article/details/89233882