0
我想使用动态查询或语句使用iBATIS来获取数据。如何在iBATIS中使用“或”语句编写查询?
例如
select * from USERS where ID=1 or ID=12 or ID= 3 or ID=27.....
,我想通过设置ID作为一个列表对象的。
我想使用动态查询或语句使用iBATIS来获取数据。如何在iBATIS中使用“或”语句编写查询?
例如
select * from USERS where ID=1 or ID=12 or ID= 3 or ID=27.....
,我想通过设置ID作为一个列表对象的。
你凸轮使用报表
<select id="selectKeys" parameterType="list"
resultMap="selectKeysResultMap">
SELECT COL1,COL2
FROM
TABLE1
WHERE COL1 IN
<foreach item="item" index="index" collection="list" open="("
separator="," close=")">
#{item}
</foreach>
</select>
在你DataConnector添加此;
Map<String,Object> inputMap = new HashMap<String,Object>();
Map<String,Object> inputMap = new HashMap<String,Object>();
inputMap.put("idList", idList);
mapper.getMcqAnswers(inputMap);
在你的DBMapper.xml中添加这个;
<select id="getMcqAnswers" resultType="your result type">
select id,answers from mcqs where id in
<foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
${item}
</foreach>
</select>
你可以这样做吗?select * from USERS where ID IN('1','12','3','27',...) –