mysql批量查询

一般批量查询的时候都是in关键字,但是在数据量大的时候,效率低下。

这个时候我们就可以考虑使用union .

xml 核心代码

<select id="selectList" resultMap="BaseResultMap" parameterType="java.util.List" >
<foreach collection="list" item="item" index="index" separator="UNION" >
(select
from table
where
id = #{item} )
</foreach>

</select>

原文地址:https://www.cnblogs.com/memoa/p/10413746.html