ibatis中 in的用法
2016-03-10 14:51
357 查看
本文摘自:http://stanlyy.iteye.com/blog/659686
ibatis中的sql语句处理in()的方法:
Xml代码
<select id="totalCustomSum" parameterClass="customReport" resultClass="customReport">
select sg.client_group_id as clientId, client_group_name as clientName,count(u.clientuser_id) as currentCount
From sys_client_group sg left join clientinfo_group g on sg.client_group_id = g.Client_group_id
left join user_info_msg u on u.clientuser_id= g.clientuser_id
<isNotEmpty property="startDate">
<![CDATA[ and u.createtime >= #startDate#]]>
</isNotEmpty>
<isNotEmpty property="endDate">
<![CDATA[ and u.createtime <= #endDate#]]>
</isNotEmpty>
<isNotEmpty property="userIdList">
and u.user_id in
<iterate property="userIdList" conjunction="," close=")" open="(" >
#userIdList[]#
</iterate>
</isNotEmpty>
group by sg.client_group_id
</select>
或者是:
Xml代码
<select id="totalCustomSum" parameterClass="customReport" resultClass="customReport">
select sg.client_group_id as clientId, client_group_name as clientName,count(u.clientuser_id) as currentCount
From sys_client_group sg left join clientinfo_group g on sg.client_group_id = g.Client_group_id
left join user_info_msg u on u.clientuser_id= g.clientuser_id
<isNotEmpty property="startDate">
<![CDATA[ and u.createtime >= #startDate#]]>
</isNotEmpty>
<isNotEmpty property="endDate">
<![CDATA[ and u.createtime <= #endDate#]]>
</isNotEmpty>
<isNotEmpty property="user_id">
and u.user_id in($user_id$)
</isNotEmpty>
group by sg.client_group_id
</select>
其中第二种方法注意 in()里面取值的符号是“$”而不是通常用的“#”
在另一个博客上写着:可以试试。
<select id="XXXX.list" parameterClass="java.util.ArrayList" resultClass="XXXXX">
select * from XXXX
<dynamic prepend=" where XXXX in">
<iterate open="(" close=")" conjunction="," >
#[]#
</iterate>
</dynamic>
</select>
传入一个List 用迭代器转换为 in (x,x,x,x,x,x,x……)
ibatis中的sql语句处理in()的方法:
Xml代码
<select id="totalCustomSum" parameterClass="customReport" resultClass="customReport">
select sg.client_group_id as clientId, client_group_name as clientName,count(u.clientuser_id) as currentCount
From sys_client_group sg left join clientinfo_group g on sg.client_group_id = g.Client_group_id
left join user_info_msg u on u.clientuser_id= g.clientuser_id
<isNotEmpty property="startDate">
<![CDATA[ and u.createtime >= #startDate#]]>
</isNotEmpty>
<isNotEmpty property="endDate">
<![CDATA[ and u.createtime <= #endDate#]]>
</isNotEmpty>
<isNotEmpty property="userIdList">
and u.user_id in
<iterate property="userIdList" conjunction="," close=")" open="(" >
#userIdList[]#
</iterate>
</isNotEmpty>
group by sg.client_group_id
</select>
或者是:
Xml代码
<select id="totalCustomSum" parameterClass="customReport" resultClass="customReport">
select sg.client_group_id as clientId, client_group_name as clientName,count(u.clientuser_id) as currentCount
From sys_client_group sg left join clientinfo_group g on sg.client_group_id = g.Client_group_id
left join user_info_msg u on u.clientuser_id= g.clientuser_id
<isNotEmpty property="startDate">
<![CDATA[ and u.createtime >= #startDate#]]>
</isNotEmpty>
<isNotEmpty property="endDate">
<![CDATA[ and u.createtime <= #endDate#]]>
</isNotEmpty>
<isNotEmpty property="user_id">
and u.user_id in($user_id$)
</isNotEmpty>
group by sg.client_group_id
</select>
其中第二种方法注意 in()里面取值的符号是“$”而不是通常用的“#”
在另一个博客上写着:可以试试。
<select id="XXXX.list" parameterClass="java.util.ArrayList" resultClass="XXXXX">
select * from XXXX
<dynamic prepend=" where XXXX in">
<iterate open="(" close=")" conjunction="," >
#[]#
</iterate>
</dynamic>
</select>
传入一个List 用迭代器转换为 in (x,x,x,x,x,x,x……)
相关文章推荐
- 一些图片
- Quartz2D 图像处理
- (二) WebService-- JDK 发布WS服务
- (三) WebService-- JDK 客户端调用
- ThinkPHP架构(一)-TP原理及路径问题及后台实现实例
- 软件工程个人作业01
- R语言中bioconductor包
- 欧几里德与扩展欧几里德算法(转)
- -bash: jps: command not found
- sql server 2005卸载记录.
- AJAX 请求出现编码问题处理过程
- idea 创建 maven web工程
- 太原UI设计师及web前端师郭文军讲网页中网格布局思路?
- Xcode 7免证书真机调试
- Weblogic和Tomcat对比
- 源码安装apache2.4遇到的问题
- Android的Manifest配置文件介绍
- Fatal error: Call to undefined function mb_internal_encoding()
- (一) WebService 简介
- float的位操作