<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语句查询多个数值
最新推荐文章于 2025-05-06 15:43:22 发布