条件sql ibatis
<!-- 多条件查询 -->
<select id="MS-CUSTOM-PANDECT-INFO-BY-CONDITIONS" resultMap="RM-CUSTOM-PANDECT-INFO-ORDER">
select t.*, d.real_name sale_name from
(SELECT custom_id ,real_name ,user_name ,type ,account_name ,under_investor ,real_name_authentication ,address ,gender ,age ,referees ,register_time ,mobile ,cert_no ,mail ,qq ,account_remainder ,multiple_rank ,active_extent ,invest_frequency ,lately_invest_time ,invest_amount ,lifecycle ,bank_cards ,platform_id FROM custom_pandect_info p
where 1=1
<dynamic>
<isNotEmpty property="customPandectInfo.realName" prepend=" and " >
real_name=#customPandectInfo.realName#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.userName" prepend=" and " >
user_name=#customPandectInfo.userName#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.type" prepend=" and " >
type=#customPandectInfo.type#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.realNameAuthentication" prepend=" and " >
real_name_authentication=#customPandectInfo.realNameAuthentication#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.address" prepend=" and " >
address=#customPandectInfo.address#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.sex" prepend=" and " >
gender=#customPandectInfo.sex#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.multipleRank" prepend=" and " >
multiple_rank=#customPandectInfo.multipleRank#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.activeExtent" prepend=" and " >
active_extent=#customPandectInfo.activeExtent#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.lifecycle" prepend=" and " >
lifecycle=#customPandectInfo.lifecycle#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.ageGroup" prepend=" and " >
age_level=#customPandectInfo.ageGroup#
</isNotEmpty>
<isEqual property="customPandectInfo.accountRemain" prepend=" and " compareValue="有">
<![CDATA[
account_remainder>0
]]>
</isEqual>
<isEqual property="customPandectInfo.accountRemain" prepend=" and " compareValue="无">
<![CDATA[
account_remainder=0
]]>
</isEqual>
<isNotEmpty property="customPandectInfo.saleName" prepend=" and ">
EXISTS (SELECT uu.custom_id ,ui.* from user_custom uu
inner JOIN user_info ui on ui.id=uu.user_id and ui.STATUS='1' and uu.status='1'
and ui.real_name LIKE #customPandectInfo.saleName#
where uu.custom_id= p.custom_id )
</isNotEmpty>
<isNotEmpty property="customPandectInfo.checkedTrades" prepend=" and ">
exists(select vest.custom_id from custom_invest_info vest
where vest.custom_id=p.custom_id and vest.trade_id
<iterate property="ids" close="))" open="in(" conjunction=",">
<![CDATA[
#customPandectInfo.checkedTrades[]#
]]>
</iterate>
</isNotEmpty>
</dynamic>
<isNotNull property="customPandectInfo.orderBy">
order by #customPandectInfo.orderBy#
</isNotNull>
LIMIT #limitStart#,#pageSize# ) t
left join user_custom c on (c.custom_id=t.custom_id and c.status='1')
left join user_info d on (d.id=c.user_id and d.status='1')
</select>
<!--查询满足条件的所有 数据 -->
<select id="MS-CUSTOM-PANDECT-INFO-BY-COUNT" resultClass="long">
SELECT count(*) FROM custom_pandect_info p
where 1=1
<dynamic>
<isNotEmpty property="customPandectInfo.realName" prepend=" and " >
real_name=#customPandectInfo.realName#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.userName" prepend=" and " >
user_name=#customPandectInfo.userName#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.type" prepend=" and " >
type=#customPandectInfo.type#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.realNameAuthentication" prepend=" and " >
real_name_authentication=#customPandectInfo.realNameAuthentication#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.address" prepend=" and " >
address=#customPandectInfo.address#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.sex" prepend=" and " >
gender=#customPandectInfo.sex#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.multipleRank" prepend=" and " >
multiple_rank=#customPandectInfo.multipleRank#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.activeExtent" prepend=" and " >
active_extent=#customPandectInfo.activeExtent#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.lifecycle" prepend=" and " >
lifecycle=#customPandectInfo.lifecycle#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.ageGroup" prepend=" and " >
age_level=#customPandectInfo.ageGroup#
</isNotEmpty>
<isEqual property="customPandectInfo.accountRemain" prepend=" and " compareValue="有">
<![CDATA[
account_remainder>0
]]>
</isEqual>
<isEqual property="customPandectInfo.accountRemain" prepend=" and " compareValue="无">
<![CDATA[
account_remainder=0
]]>
</isEqual>
<isNotEmpty property="customPandectInfo.saleName" prepend=" and ">
EXISTS (SELECT uu.custom_id ,ui.* from user_custom uu
inner JOIN user_info ui on ui.id=uu.user_id and ui.STATUS='1' and uu.status='1'
and ui.real_name LIKE #customPandectInfo.saleName#
where uu.custom_id= p.custom_id )
</isNotEmpty>
<isNotEmpty property="customPandectInfo.checkedTrades" prepend=" and ">
exists(select vest.custom_id from custom_invest_info vest
where vest.custom_id=p.custom_id and vest.trade_id
<iterate property="ids" close="))" open="in(" conjunction=",">
<![CDATA[
#customPandectInfo.checkedTrades[]#
]]>
</iterate>
</isNotEmpty>
</dynamic>
</select>
公用公共条件
<!--客户列表所有查询条件 -->
<sql id="MS-CUSTOM-PANDECT-INFO-QUERY-WHERE">
<dynamic prepend="WHERE">
<isNotEmpty property="customPandectInfo.realName" prepend=" and ">
real_name=#customPandectInfo.realName#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.userName" prepend=" and ">
user_name=#customPandectInfo.userName#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.type" prepend=" and ">
type=#customPandectInfo.type#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.realNameAuthentication"
prepend=" and ">
real_name_authentication=#customPandectInfo.realNameAuthentication#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.address" prepend=" and ">
address=#customPandectInfo.address#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.sex" prepend=" and ">
gender=#customPandectInfo.sex#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.multipleRank"
prepend=" and ">
multiple_rank=#customPandectInfo.multipleRank#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.activeExtent"
prepend=" and ">
active_extent=#customPandectInfo.activeExtent#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.lifecycle"
prepend=" and ">
lifecycle=#customPandectInfo.lifecycle#
</isNotEmpty>
<isNotEmpty property="customPandectInfo.ageGroup" prepend=" and ">
age_level=#customPandectInfo.ageGroup#
</isNotEmpty>
<isEqual property="customPandectInfo.accountRemain" prepend=" and "
compareValue="有">
<![CDATA[
account_remainder>0
]]>
</isEqual>
<isEqual property="customPandectInfo.accountRemain" prepend=" and "
compareValue="无">
<![CDATA[
account_remainder=0
]]>
</isEqual>
<isNotEmpty property="customPandectInfo.userId" prepend=" and">
exists (select uuu.custom_id from user_custom uuu
where uuu.status='1' and uuu.user_id=#customPandectInfo.userId#
and uuu.custom_id=p.custom_id)
</isNotEmpty>
<isNotEmpty property="customPandectInfo.saleName" prepend=" and ">
EXISTS (SELECT uu.custom_id from user_custom uu
inner JOIN user_info ui on ui.id=uu.user_id and ui.STATUS='1' and
uu.status='1'
and ui.real_name LIKE #customPandectInfo.saleName#
where uu.custom_id= p.custom_id )
</isNotEmpty>
<isNotEmpty property="customPandectInfo.ids" prepend=" and ">
exists(select vest.custom_id from custom_invest_info vest
where vest.custom_id=p.custom_id and vest.trade_id
<iterate property="customPandectInfo.ids" close="))" open="in("
conjunction=",">
<![CDATA[
#customPandectInfo.ids[]#
]]>
</iterate>
</isNotEmpty>
<isNotNull property="customPandectInfo.status" prepend=" and">
exists(select cci.custom_id from custom_communicate_info cci where
cci.custom_id=p.custom_id and
cci.commu_status=#customPandectInfo.status#
)
</isNotNull>
</dynamic>
</sql>
<!-- 多条件查询 -->
<select id="MS-CUSTOM-PANDECT-INFO-BY-CONDITIONS" resultMap="RM-CUSTOM-PANDECT-INFO-ORDER">
<![CDATA[ select t.*, d.real_name sale_name from
(SELECT custom_id ,real_name ,user_name ,type ,account_name ,under_investor ,real_name_authentication ,address ,gender ,age ,referees ,register_time ,mobile ,cert_no ,mail ,qq ,account_remainder ,multiple_rank ,active_extent ,invest_frequency ,lately_invest_time ,invest_amount ,lifecycle ,bank_cards ,platform_id FROM custom_pandect_info p
]]>
<include refid="MS-CUSTOM-PANDECT-INFO-QUERY-WHERE" />
<isNotEmpty property="customPandectInfo.orderBy">
order by $customPandectInfo.orderBy$
</isNotEmpty>
<![CDATA[ LIMIT #limitStart#,#pageSize# ) t
left join user_custom c on (c.custom_id=t.custom_id and c.status='1')
left join user_info d on (d.id=c.user_id and d.status='1')
]]>
</select>
<!--查询满足条件的所有 数据 -->
<select id="MS-CUSTOM-PANDECT-INFO-BY-COUNT" resultClass="long">
<![CDATA[ SELECT count(*) FROM custom_pandect_info p
]]>
<include refid="MS-CUSTOM-PANDECT-INFO-QUERY-WHERE" />
</select>
条件sql ibatis的更多相关文章
- 列表查询组件代码, 简化拼接条件SQL语句的麻烦
列表查询组件代码, 简化拼接条件SQL语句的麻烦 多条件查询
- dedecms有条件sql注入(x0day)
https://www.t00ls.net/thread-35569-1-1.html http://localhost/dedecms/plus/advancedsearch.php?mid=1&a ...
- 反连接NOT EXISTS子查询中有or 谓词连接条件SQL优化一例
背景 今天在日常数据库检查中,发现一SQL运行时间特别长,于是抓取出来,进行优化. 优化前: 耗时:503s 返回:0 SQL代码 SELECT * FROM MM_PAYABLEMONEY_TD P ...
- TP多条件sql查询,分组排序
$k=M('order a'); $bj=$k->join("left join __CHANGE__ b on b.tb_name='order'and a.order_id=b.t ...
- sql ibatis
<!-- 写入单位下当前参保人员 --> <insert id="insertTempCaz043" parameterClass="map" ...
- iBatis第四章:动态SQL的用法
一.什么是动态SQL,以及使用动态SQL的好处 所谓动态SQL,是针对静态SQL而言的,静态SQL的SQL语句是固定的,使用动态SQL是为了增强SQL的灵活性和复用性,可以用一个动态SQL达到在不同条 ...
- C# SQL多条件查询拼接技巧
本文转载:http://blog.csdn.net/limlimlim/article/details/8638080 #region 多条件搜索时,使用List集合来拼接条件(拼接Sql) Stri ...
- QueryBuilder 前端构造SQL条件的插件使用方法
页面引入JS等: <script type="text/javascript" src="/qysds-jx/pages/gzrw/js/jquery.js&quo ...
- Ibatis 3.0 之前使用的都是2.0 3.0与2.0的内容有很大的不同
以前用过ibatis2,但是听说ibatis3有较大的性能提升,而且设计也更合理,他不兼容ibatis2.尽管ibatis3还是beta10的状态,但还是打算直接使用ibatis3.0, ibatis ...
随机推荐
- 危险,几条可致命的Linux命令!
1. rm -rf 命令 rm -rf命令是删除文件夹及其内容最快的方式之一.仅仅一丁点的敲错或无知都可能导致不可恢复的系统崩坏.下列是一些rm 命令的选项.rm 命令在Linux下通常用来删除文件. ...
- Java中编写一个完美的equals方法
首先看下Java语言规范对equals方法的要求: 1,自反性,对于任何非控引用x,x.equals(x)都应该返回true. 2,对称性,对于任何引用x和y,如果x.equals(y)返回true, ...
- c# PID算法入门
离开工控行业已经有一段时间了,最近回忆起以前的工作,又对 PID 算法有了兴趣.所以写了一个小项目,希望可以帮到需要的人,也算是对那段工作经历的一个总结. 这是一个 winform 的项目.负载是一个 ...
- Android中使用VideoView 播放视频
VideoView一般结合MediaController类使用,它会提供一个友好的图形界面,通过该界面可以控制视频的播放 package com.test.videoview; import andr ...
- React 表单元素实例
代码实例: <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset=" ...
- Qt 【tableview+delegate list越界 ,删除了list,model上还有存在delegate】
bug如图所示: 模型是n*4 ,因为是越界了每次最后一行点击都会出现这样的 警告,在控制台显示以下,然后程序崩溃. ASSERT failure in Qlist<T>::operat ...
- DEDE织梦标签经常调用的内容
DEDE织梦标签名称:{/dede:arclist} 详解 标签名称:arclist标记简介:织梦常用标记,也称为自由列表标记,其中imglist.imginfolist.specart.coolar ...
- Vue学习笔记【19】——Vue中的动画(使用第三方 CSS 动画库)
导入动画类库: <link rel="stylesheet" type="text/css" href="./lib/animate.css& ...
- Vue学习笔记【8】——在Vue中使用样式
使用class样式 数组 <h1 :class="['red', 'thin']">这是一个邪恶的H1</h1> 2.数组中使用三元表达式 <h1 : ...
- 「AHOI / HNOI2018」转盘 解题报告
「AHOI / HNOI2018」转盘 可能是我语文水平不太行... 首先可以猜到一些事实,这个策略一定可以被一个式子表示出来,不然带修修改个锤子. 然后我们发现,可以枚举起点,然后直接往前走,如果要 ...