mybatis 模糊查詢like問(wèn)題
映射文件中的like '%' #{symptomName} '%' 就報(bào)語(yǔ)法錯(cuò)誤
<if test="symptomName != null and !"".equals(symptomName.trim())">
? ?and symptom_name like '%' #{symptomName} '%'
</if>
Caused by: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'name like '%' ? '%') tmp_count', expect RPAREN, actual QUES pos 174, line 6, column 39, token QUES : select count(0) from (select
??????? ?
??????? symptom_code,symptom_name,synonym
??? ?
??????? from? western_medicine_symptone_synonym
???????? WHERE? symptom_name like '%' ? '%') tmp_count
2018-05-29
改成這樣 ?and symptom_name like? concat('%' ,#{symptomName}, '%')
2018-03-05
你把下面一段放到Mysql中運(yùn)行試一下。不過(guò)為什么要用select count from呢