
mybatis动态sql报错征解
在使用mybatis进行动态sql操作时,遇到报错提示"badsql",可能的原因是sql语句存在语法错误。
针对提供的sql语句:
select * from table aa.project_id=#{projectid} and a.id != #{id} and a.status=3 and a.id_card = #{code} and a.unit_code = #{code}
修改后,正确的sql语句应该如下:
select * from table aa.project_id=#{projectId} and a.id != #{id} and a.status=3 and a.id_card = #{code} and a.unit_code = #{code}
修改后的部分包括:
- 将test='type == idcard'修改为test="type == 'idcard'",添加了引号。
- 将test='type == unitcode'修改为test="type == 'unitcode'",添加了引号。
- 添加了
语句块。
修改后,sql语句的语法正确,可以正常执行。










