示例1: in中应使用${}而不是#{}
String deviceStatus="1,2,5,7";
in中使用#{}
SELECT * FROM TABLE_NAME
WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(`status`, ',', 3), ',', -1) in (#{deviceStatus})
查询不到数据
in中使用${}
SELECT * FROM TABLE_NAME
WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(`status`, ',', 3), ',', -1) in (#{deviceStatus})
能查询到符合条件的数据
示例2
List<String> deviceStatusList = Arrays.asList(1,2,5,7);
SELECT * FROM TABLE_NAME
WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(d.`status, ',', 3), ',', -1) in
<foreach collection="deviceStatusList" item="item" index="index" open="(" separator="," close=")">#{item}
</foreach>