例如 [select * from tableName where id In(1,2,3,4)]
<select id="findListById" resultType="Goods">
SELECT * FROM TABLE_NAME WHERE g.id IN
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="findListById" resultType="Goods">
SELECT * FROM TABLE_NAME WHERE g.id IN
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
本文介绍如何使用SQL IN子句进行批量查询,并通过MyBatis的foreach元素实现动态SQL,提高批量查询的灵活性和效率。
643

被折叠的 条评论
为什么被折叠?



