Mybaties

作者: ShawnCaffeine | 来源:发表于2019-08-01 11:25 被阅读0次

模糊查询例子:

<select id="selectDeviceCount"  resultType="java.lang.Integer" >
    select count(1) from t_device_info
      <where>
          del_flag=0
          <if test="phoneName != null and phoneName != ''">
              AND  phone_name like concat(concat('%',#{phoneName,jdbcType=VARCHAR}),'%')
          </if>
          <if test="serialNumber != null and serialNumber != ''">
          AND serial_number like concat(concat('%',#{serialNumber,jdbcType=VARCHAR}),'%')
          </if>
      </where>
  </select>
    select
    <include refid="Base_Column_List" />
    from t_device_info
    <where>
      del_flag=0
      <if test="phoneName != null and phoneName != ''">
        AND  phone_name like concat(concat('%',#{phoneName,jdbcType=VARCHAR}),'%')
      </if>
      <if test="serialNumber != null and serialNumber != ''">
        AND serial_number like concat(concat('%',#{serialNumber,jdbcType=VARCHAR}),'%')
      </if>
    </where>
    order by id desc
    <if test="start != null and limit != '' ">
      limit #{start}, #{limit}
    </if>
  </select>

类似这种

phone_name like concat(concat('%',#{phoneName,jdbcType=VARCHAR}),'%')

相关文章

网友评论

      本文标题:Mybaties

      本文链接:https://www.haomeiwen.com/subject/onhqdctx.html