<!-- 多条件查询 -->
<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. PHP中global与$GLOBALS的区别

    单一个global是一个关键字,通常附加在变量前,用于将变量声明至全局作用域: $GLOBALS是预定义的超全局变量,把变量扔到里边的话一样可以带到全局去. $GLOBALS 是一个关联数组,每一个变 ...

  2. Cocos2d-x之Director

    |   版权声明:本文为博主原创文章,未经博主允许不得转载. Director类简介 在Cocos2d-x-3.x引擎中,采用节点树形结构来管理游戏对象,一个游戏可以划分为不同的场景,一个场景又可以分 ...

  3. JPA派生标识符2

    @Entity@Table(name = "adam_importfile")@IdClass(BusinessAdviserFileId.class)public class B ...

  4. UML指南系列——活动图

    活动图用来描述传统意义上的流程图

  5. Android组件内核之Activity调用栈分析(一)

    阿里P7Android高级架构进阶视频免费学习请点击:https://space.bilibili.com/474380680 导语 我们陈述一下Activity,Activity是整个应用用户交互的 ...

  6. CG-CTF misc部分wp

    将Misc剥离出来了,已完结(coding gay不想做了) MISC1,图种一听图种,现将图片的GIF改为zip,然后解压得到另一张动图看动图最后一句话为‘都深深的出卖了我’,得到 flag2, 丘 ...

  7. LeetCode Array Easy 27. Remove Element 解题

    Given an array nums and a value val, remove all instances of that value in-place and return the new ...

  8. 2019-5-21-win10-uwp-url-encode

    title author date CreateTime categories win10 uwp url encode lindexi 2019-5-21 9:54:7 +0800 2018-2-1 ...

  9. Mac下homebrew的安装与卸载

    mac系统常用的软件安装工具就是homebrew 个人认为通过brew安装比较简单,下面介绍下如何安装 安装和卸载homebrew 安装 /usr/bin/ruby -e "$(curl - ...

  10. nginx信号及平滑升级

    1.nginx信号 nginx进程处理命令: kill -signals PID PID即nginx进程ID signals的参数解释如下所示: TERM,INT快速关闭进程 QUIT优雅的关闭,如果 ...