You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%逸%'' at line 1

2023-03-14,,

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<!-- 命名空间要和接口的全限定名相同 -->
<mapper namespace="com.imp.IStudents">
<select id="selectLike" parameterType="String" resultType="students">
select * from students where name like '%${value}%'
</select> </mapper>

IStudents.xml

org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%逸%'' at line 1
### The error may exist in com/imp/IStudents.xml
### The error may involve com.imp.IStudents.selectLike-Inline
### The error occurred while setting parameters
### SQL: select * from students name like '%逸%'
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%逸%'' at line 1

错误原因:select语句写错了

select * from students where name like '%逸%'

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%逸%'' at line 1的相关教程结束。

《You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%逸%'' at line 1.doc》

下载本文的Word格式文档,以方便收藏与打印。