<select id="countDTO" resultType="java.lang.Integer" parameterType="com.DTO"> select count(id)//主键id from ${tableName}//你的表名 where is_deleted = 0 //id集合查询传入product_id 的集合productIds <if test="productIds != null and productIds.size() > 0 ">//集合判空 and product_id in <foreach collection="productIds" item="code" open="(" close=")" separator=","> #{code} </foreach> </if> //模糊匹配specialName <if test="specialName != null and specialName != '' "> and special_name like concat('%',replace(#{specialName,jdbcType=VARCHAR},'%','/%'),'%') escape '/' </if> //recordDateStart 大于等于开始时间小于等于结束时间 <if test="recordDateStart != null"> and record_date_start <![CDATA[>=]]> #{recordDateStart} </if> <if test="recordDateEnd != null"> and record_date_end <![CDATA[<=]]> #{recordDateEnd} </if> </select>
MyBatis查询 传入条件 模糊匹配 日期范围 id集合
最新推荐文章于 2022-12-28 10:01:45 发布