如何在mybatis SQL查询中使用IN
2014-11-26 09:40
459 查看
<!-- 刪除應用市場信息 -->
<delete id="delApplyMarker">
delete from bi_applymarker where apply_id in <foreach item="item" index="index" collection="ids"
open="(" separator="," close=")">
#{item}
</foreach>
</delete>
/**
* @content 刪除所選中的應用市場
* @time 2014/10/21
* */
public void delApplyMarker(@Param(value="ids")List<Integer> applyMarkerId);
/**
* @content 刪除應用市場詳情
* @time 2014/10/21
* */
@RequestMapping(value="/delApplyMarker",method=RequestMethod.GET)
@ResponseBody
public String delApplyMarker(HttpServletRequest request){
ResultToJackson result = new ResultToJackson();
Map<String, Object> applyMarker_map = new HashMap<String, Object>();//返回給前臺的數據
try {
String applyMarkerId = request.getParameter("applyMarkerId");
BIapplyMarkerMapper bIapplyMarkerMapper = (BIapplyMarkerMapper) factory.getBusinessProduct("applyMarker");
String[] applyMarkerIds = applyMarkerId.split(",");
List<Integer> ids = new ArrayList<Integer>();
for(int i=0;i<applyMarkerIds.length;i++){
ids.add(Integer.parseInt(applyMarkerIds[i]));
}
bIapplyMarkerMapper.delApplyMarker(ids);
applyMarker_map.put("status", "true");
} catch (Exception e) {
e.printStackTrace();
applyMarker_map.put("status", "false");
}
return result.getResultFromMap(applyMarker_map);
}
}
<delete id="delApplyMarker">
delete from bi_applymarker where apply_id in <foreach item="item" index="index" collection="ids"
open="(" separator="," close=")">
#{item}
</foreach>
</delete>
/**
* @content 刪除所選中的應用市場
* @time 2014/10/21
* */
public void delApplyMarker(@Param(value="ids")List<Integer> applyMarkerId);
/**
* @content 刪除應用市場詳情
* @time 2014/10/21
* */
@RequestMapping(value="/delApplyMarker",method=RequestMethod.GET)
@ResponseBody
public String delApplyMarker(HttpServletRequest request){
ResultToJackson result = new ResultToJackson();
Map<String, Object> applyMarker_map = new HashMap<String, Object>();//返回給前臺的數據
try {
String applyMarkerId = request.getParameter("applyMarkerId");
BIapplyMarkerMapper bIapplyMarkerMapper = (BIapplyMarkerMapper) factory.getBusinessProduct("applyMarker");
String[] applyMarkerIds = applyMarkerId.split(",");
List<Integer> ids = new ArrayList<Integer>();
for(int i=0;i<applyMarkerIds.length;i++){
ids.add(Integer.parseInt(applyMarkerIds[i]));
}
bIapplyMarkerMapper.delApplyMarker(ids);
applyMarker_map.put("status", "true");
} catch (Exception e) {
e.printStackTrace();
applyMarker_map.put("status", "false");
}
return result.getResultFromMap(applyMarker_map);
}
}
相关文章推荐
- Mybatis查询SQL中如何使用in?
- mybatis sql in 查询(mybatis sql语句传入参数是list)mybatis中使用in查询时in怎么接收值
- mybatis使用foreach实现sql的in查询
- mybatis查询sql中in条件使用(foreach)
- mybatis查询sql中in条件使用(foreach)
- Mybatis 中sql 使用in(#{item})无法查询解决办法
- mybatis 中 查询sql使用in
- 如何在Sql Server上使用一条SQL查询结果总数并且分页
- 学习并使用了两种linq to entity 的实现sql关键字in的查询方法
- SQL存储过程如何使用IN关键字
- 在SQL查询中使用LIKE来代替IN
- sql 上一条、下一条记录再次改进(文章底部红色字体)及如何在子查询中使用limit语法!我这个脑子啊
- 如何使用SQLPLUS分析SQL语句(查询执行计划跟踪)
- mybatis sql in 查询
- sql 调优之-在子查询中使用exist还是 in
- mysql 按年度、季度、月度、周、日SQL统计查询,mysql 存储过程 中 in 和 FIND_IN_SET 传递多个参数的使用
- 构造使用IN子句的动态Transact-SQL方法进行编号查询
- 数据库中如何使用SQL查询连续号码段
- 如何使用Oracle查询并删除重复记录的SQL语句
- 详解如何使用SQL中文分词组件查询表记录