<select id="selectByFieldValues" parameterType="map" resultMap="yourResultMap">
SELECT *
FROM your_table
<where>
<if test="fieldValues != null and fieldValues != ''">
<!-- 使用动态SQL生成IN语句 -->
AND your_field IN
<foreach item="item" index="index" collection="fieldValues.split(',')" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
Mybatis中xml,要判断参数不为空并且使用IN语句查询多个数值
最新推荐文章于 2024-07-17 16:35:42 发布