<!-- 多条件查询 -->
<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的更多相关文章

  1. 列表查询组件代码, 简化拼接条件SQL语句的麻烦

    列表查询组件代码, 简化拼接条件SQL语句的麻烦 多条件查询

  2. dedecms有条件sql注入(x0day)

    https://www.t00ls.net/thread-35569-1-1.html http://localhost/dedecms/plus/advancedsearch.php?mid=1&a ...

  3. 反连接NOT EXISTS子查询中有or 谓词连接条件SQL优化一例

    背景 今天在日常数据库检查中,发现一SQL运行时间特别长,于是抓取出来,进行优化. 优化前: 耗时:503s 返回:0 SQL代码 SELECT * FROM MM_PAYABLEMONEY_TD P ...

  4. TP多条件sql查询,分组排序

    $k=M('order a'); $bj=$k->join("left join __CHANGE__ b on b.tb_name='order'and a.order_id=b.t ...

  5. sql ibatis

    <!-- 写入单位下当前参保人员 --> <insert id="insertTempCaz043" parameterClass="map" ...

  6. iBatis第四章:动态SQL的用法

    一.什么是动态SQL,以及使用动态SQL的好处 所谓动态SQL,是针对静态SQL而言的,静态SQL的SQL语句是固定的,使用动态SQL是为了增强SQL的灵活性和复用性,可以用一个动态SQL达到在不同条 ...

  7. C# SQL多条件查询拼接技巧

    本文转载:http://blog.csdn.net/limlimlim/article/details/8638080 #region 多条件搜索时,使用List集合来拼接条件(拼接Sql) Stri ...

  8. QueryBuilder 前端构造SQL条件的插件使用方法

    页面引入JS等: <script type="text/javascript" src="/qysds-jx/pages/gzrw/js/jquery.js&quo ...

  9. Ibatis 3.0 之前使用的都是2.0 3.0与2.0的内容有很大的不同

    以前用过ibatis2,但是听说ibatis3有较大的性能提升,而且设计也更合理,他不兼容ibatis2.尽管ibatis3还是beta10的状态,但还是打算直接使用ibatis3.0, ibatis ...

随机推荐

  1. 数据分析系列篇:玩转excel

    数据分析系列篇:玩转excel 不知道现在怎么也变得这么鸡婆,连excel都要准备写一篇.没办法,还有很多不是做数据的小伙伴们不会excel啊,抱着不抛弃.不放弃的态度,就讲下excel如何玩转.其实 ...

  2. VS2008的使用

    文章转载自:http://www.cnblogs.com/aduck/archive/2011/11/11/2245460.html 1.如何在vc2008中显示行号 中文版: 菜单-工具-选项 在新 ...

  3. zoom:1总结

    zoom:1确实帮我们解决了不少ie下的bug,但是它的来龙去脉,又有多少人知道呢? 所以我老生常谈,说一下它的来龙去脉. Zoom属性是IE浏览器的专有属性, 它可以设置或检索对象的缩放比例.先来一 ...

  4. export的用法

    定义环境变量并且赋值 # export MYENV= //定义环境变量并赋值 # export -p declare -x HOME=“/root“ declare -x LANG=“zh_CN.UT ...

  5. 1005 -- I Think I Need a Houseboat

    I Think I Need a Houseboat Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 105186   Acc ...

  6. 读书笔记-----javascript基本数据类型

    由于js基础差, 记性也不好,准备一边读书一边做记录,希望这样能加深一下记忆 /*   第一天     */ javascript 基本数据类型 js一共只有五种数据类型 Undefined,  Nu ...

  7. 微信小程序app.json文件常用全局配置

    小程序根目录下的 app.json 文件用来对微信小程序进行全局配置,决定页面文件的路径.窗口表现.设置网络超时时间.设置多 tab 等. JOSN文件不允许注释,下面为了学习加上注释,粘贴需要的片段 ...

  8. LeetCode Array Easy121. Best Time to Buy and Sell Stock

    Description Say you have an array for which the ith element is the price of a given stock on day i. ...

  9. JNI原理与静态、动态注册

    前言 JNI不仅仅在NDK开发中应用,它更是Android系统中Java与Native交互的桥梁,不理解JNI的话,你就只能停留在Java Framework层.这一个系列我们来一起深入学习JNI. ...

  10. MySQL数据库企业级应用实践(多实例源码编译)

    MySQL数据库企业级应用实践(多实例源码编译) 链接:https://pan.baidu.com/s/1ANGg3Kd_28BzQrA5ya17fQ 提取码:ekpy 复制这段内容后打开百度网盘手机 ...