数据库中某表的一个字段为name,我需要对它进行模糊查询的时候使用了下面的方法,解决了这个问题。
<select id="findList" resultType="DwfxGzysxl">
SELECT
<include refid="dwfxGzysxlColumns"/>
FROM v_dwfx_gzysxl a
<include refid="dwfxGzysxlJoins"/>
<where>
<if test="name != null and name != ''">
AND a.name LIKE
<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
</choose>
</select>