运行mybatis时报了org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.sql.SQLException: Operand should contain 1 column(s)
既然是sql报错,应该是sql语句写错了,然后我看了下语句发现少写了连接函数。
原句是这样的
select * from t_user where user_name like concat('%',#{username},'%') and password like ('%',#{password},'%')
改为
select * from t_user where user_name like concat('%',#{username},'%') and password like concat('%',#{password},'%')正常
MyBatis SQL语句修正
本文介绍了一个在使用MyBatis过程中遇到的SQL错误案例。由于缺少正确的连接函数导致查询失败,通过调整like子句中的concat函数解决了问题。
2810

被折叠的 条评论
为什么被折叠?



