<if test="name != null and name != ''">
<bind name="pattern" value="'%' +name + '%'" />
and name like #{pattern}
</if>
select * from prize where name like CONCAT('%','1','%');
两条sql最终实现结果一致,都是为了得到 %name%
<if test="name != null and name != ''">
<bind name="pattern" value="'%' +name + '%'" />
and name like #{pattern}
</if>
select * from prize where name like CONCAT('%','1','%');
两条sql最终实现结果一致,都是为了得到 %name%