1、sql select 查询

<select id="query"  resultType="CfCurrbusilogEntity" >
select
cb.bizid bizid,
cb.phone phone,
cb.ispno ispno,
cb.ipstype ipstype,
cb.province province,
cb.facevalue facevalue,
cb.orderid orderid,
cb.cporderno cporderno,
cb.systransno systransno,
cb.responsecode responsecode,
cb.spprice spprice,
cb.spno spno,
cb.apprice apprice,
cb.apno apno,
cb.createtime createtime,
cb.updatetime updatetime,
cb.status status,
ac.acname acname,
c.cname cname,
p.pname pname from
CF_CURRBUSILOG CB
LEFT JOIN CF_ACCESSCLIENT AC
ON CB.APNO = AC.ID
LEFT JOIN CF_CUSTOMER C
ON AC.CID = C.ID
LEFT JOIN CF_PROVINCE P
ON CB.PROVINCE = P.PNO
WHERE
(
1 =1
and cb.createtime between REPLACE(#{param1.begintime},'-','') AND CONCAT(REPLACE(#{param1.endtime},'-',''),'99')
<!--
<if test="param1.begintime!='' and param1.begintime!=null and param1.endtime!='' and param1.endtime!=null">
and cb.createtime between #{param1.begintime} and #{param1.endtime}
</if> -->
<if test="param1.cid!='' and param1.cid!=null">
and c.id = #{param1.cid}
</if>
<if test="param1.acid!='' and param1.acid!=null">
and ac.id = #{param1.acid}
</if>
<if test="param1.ispno!='' and param1.ispno!=null">
and cb.ispno = #{param1.ispno}
</if>
<if test="param1.province!='' and param1.province!=null">
and cb.province = #{param1.province}
</if>
<if test="param1.ipstype!='' and param1.ipstype!=null">
and cb.ipstype = #{param1.ipstype}
</if>
<if test="param1.status!='' and param1.status!=null">
<if test='param1.status == "4" '>
and cb.status in( '3', '4')
</if>
<if test='param1.status != "4" '>
and cb.status = #{param1.status}
</if>
</if>
<if test="param1.facevalue!='' and param1.facevalue!=null">
and cb.facevalue like CONCAT('%',#{param1.facevalue},'%' )
</if>
<if test="param1.systransno!='' and param1.systransno!=null">
and cb.systransno = #{param1.systransno}
</if>
<if test="param1.orderid!='' and param1.orderid!=null">
and cb.orderid = #{param1.orderid}
</if>
<if test="param1.phone!='' and param1.phone!=null">
and cb.phone like CONCAT('%',#{param1.phone},'%' )
</if>
)
order by cb.updatetime desc
limit #{start},#{length}
</select>

2、sql insert

 <!-- 插入数据 -->
<insert id="insertBlack" parameterType="BlacklistEntity">
INSERT INTO BLACKLIST
(
BLACKID,
BLACKTYPE,
BLACKVALUE,
ACTIONID,
REMARK,
OVERTIME,
STATUS
)
VALUES
(
#{blackid},
#{blacktype},
#{blackvalue},
#{actionid},
#{remark},
#{overtime},
#{status}
)
</insert>

3、sql update

 <!-- 修改数据 -->
<update id="updateblack" parameterType="BlacklistEntity">
UPDATE
BLACKLIST
<set>
<if test="overtime!='' and overtime!=null">
OVERTIME = #{overtime},
</if>
<if test="blacktype!='' and blacktype!=null">
BLACKTYPE = #{blacktype},
</if>
<if test="blackvalue!='' and blackvalue!=null">
BLACKVALUE = #{blackvalue},
</if>
<if test="actionid!='' and actionid!=null">
ACTIONID = #{actionid},
</if>
<if test="status!='' and status!=null">
STATUS = #{status},
</if>
<if test="remark!='' and remark!=null">
REMARK = #{remark}
</if>
</set>
WHERE
BLACKID = #{blackid}
</update>

4、sql delete

 <!-- 删除数据 -->
<delete id="deleteblack" parameterType="String">
DELETE FROM
BLACKLIST
WHERE
BLACKID=#{blackid}
</delete>

Mybatis中常见的SQL DML的更多相关文章

  1. 【mybatis深度历险系列】mybatis中的动态sql

    最近一直做项目,博文很长时间没有更新了,今天抽空,学习了一下mybatis,并且总结一下.在前面的博文中,小编主要简单的介绍了mybatis中的输入和输出映射,并且通过demo简单的介绍了输入映射和输 ...

  2. mybatis中的动态SQL

    在实际开发中,数据库的查询很难一蹴而就,我们往往要根据各种不同的场景拼接出不同的SQL语句,这无疑是一项复杂的工作,我们在使用mybatis时,mybatis给我们提供了动态SQL,可以让我们根据具体 ...

  3. 6.Mybatis中的动态Sql和Sql片段(Mybatis的一个核心)

    动态Sql是Mybatis的核心,就是对我们的sql语句进行灵活的操作,他可以通过表达式,对sql语句进行判断,然后对其进行灵活的拼接和组装.可以简单的说成Mybatis中可以动态去的判断需不需要某些 ...

  4. Mybatis中常用的SQL

    1.BaseResultMap <resultMap id="BaseResultMap" type="com.stylefeng.guns.common.pers ...

  5. SSM-MyBatis-05:Mybatis中别名,sql片段和模糊查询加getMapper

    ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 简单概述一下本讲 别名,sql片段简单写一下,模糊查询多写一点 一.别名 <typeAliases> ...

  6. mybatis中常见的问题总结

    如下所有举例基于springboot+mybatis项目中,SSH使用mybatis的写法也一样,只是形式不同而已 问题1.org.apache.ibatis.binding.BindingExcep ...

  7. mybatis中的动态SQL语句

    有时候,静态的SQL语句并不能满足应用程序的需求.我们可以根据一些条件,来动态地构建 SQL语句. 例如,在Web应用程序中,有可能有一些搜索界面,需要输入一个或多个选项,然后根据这些已选择的条件去执 ...

  8. mybatis中的动态SQL(IF Chooes When Where Set ForEach SQL片段)

    mapper: public interface BlogMapper { List<Blog> getBlogByIF(Map map); } IF <select id=&quo ...

  9. mybatis中设置打印sql语句application.yml

    在application.yml配置文件中,找到数据源设置,添加: mybatis: configuration: log-impl:org.apache.ibatis.logging.stdout. ...

随机推荐

  1. Linux查看文件最后几行的命令,日志的福音啊

    tail -n 20 filename说明:显示filename最后20行

  2. ubuntu下如何安装及使用 pysvn-workbench

    网上对于 pysvn-workbench 的教程几乎没有,没办法,只好去官网自学了,现在能正常上传资料了,写点东西,以免今后忘了 安装方面:在新立得中查找svn-workbench,subversio ...

  3. emulator shortcut

    Alt+Enter Maximizes the emulator. Ctrl+F11 Changes the orientation of the emulator from landscape to ...

  4. C#中String和stringBuilder的区别

    Stringbuilder类是直接用于字符串操作的类,打个比方把(1)string aa="123456";(2)aa+="789"; (3)StringBui ...

  5. WINCE下进程间通信(一)

    WINCE下进程间通信(一) 在WINCE开发中经常需要在不同的进程之间传递.共享数据,总结了一下,WINCE下进程间通信常用的方式有:Windows消息,共享内存,socket通信,管道,全局原子, ...

  6. (转)Eclipse中使用Ant

    Eclipse中使用Ant 分类: JAVA 工具 服务器2014-08-05 09:59 5507人阅读 评论(0) 收藏 举报 anteclipse http://286.iteye.com/bl ...

  7. 一个mapreduce得到需要计算单词概率的基础数据

    第一步,先计算需要计算概率的词频,单词种类数,类别单词总数(类别均是按照文件夹名区分)(基础数据以及分词了,每个单词一行,以及预处理好) package org.lukey.hadoop.classi ...

  8. hrbustoj 1125 循环小数 II(小数变分数+极限思想)

    #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> #i ...

  9. 删除DriverStore\FileRepository文件夹后,设备驱动无法安装,提示“没有为设备信息集或元素选择驱动程序(代码 28)”的解决办法

    前言: 我前几天手贱,整个FileRepository删除掉了,之后重启就出现了让人蛋疼的这个问题,因为出于各种原因不想重装系统,百度轮番换搜索词无果,虽然驱动装上了但新设备依然无法自动安装驱动等“一 ...

  10. UVa 816 Abbott的复仇(BFS)

    寒假的第一道题目,在放假回家颓废了两天后,今天终于开始刷题了.希望以后每天也能多刷几道题. 题意:这道BFS题还是有点复杂的,给一个最多9*9的迷宫,但是每个点都有不同的方向,每次进入该点的方向不同, ...