MyBatis中xml文件中模糊查询的写法

来源:互联网 发布:淘宝店如何提升销量 编辑:程序博客网 时间:2024/05/17 23:23

数据库中某表的一个字段为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> 





1 1
原创粉丝点击