模糊查询例子:
<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>
网友评论