mysql 批量查询

//        for (Map m : rangeList) {
// String str = m.get("value").toString();
// String value;
// if (str.contains(",")) {
// List<String> list = Arrays.asList(str.split(","));
// value = getValue(list);
// m.put("value", value);
// }
// }


Impl ----->>

private String getValue(List<String> list) {
Map map = tbHospitalMapper.selectByIds(list);
return map.get("name").toString();
}

Mapper-------->>
Map selectByIds(List<String> list);


Xml--------->>

<select id="selectByIds" parameterType="list" resultType="java.util.Map">
SELECT
IFNULL(GROUP_CONCAT(name) ,'') name
from tb_hospital
where id in
<foreach collection="list" index="index" item="item" open="("
separator="," close=")">
#{item}
</foreach>
</select>





原文地址:https://www.cnblogs.com/guagua-join-1/p/10936011.html