mysql数据库的xml模糊查询
- mybatis框架的xml中<= , >=解析会出现问题,编译报错,所以需要转译
- 正常的是使用%xxxx% ,现在需要使用 concat(’%’,#{xxxx},’%’)
<?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.ws.firestation.mapper.TradeRecordMapper">
<select id="listsome" resultType="com.ws.firestation.entity.po.TradeRecord">
select * from firecab.trade_record
where 1=1
<if test= "goodsName !=null and goodsName !=''">
and goods_name like concat('%',#{goodsName},'%')
</if>
<if test= "serverId !=null and serverId !=''">
and server_id like concat('%',#{stationId},'%')
</if>
</select>
</mapper>