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. STL笔记之【map之移除元素】

    //---------------------------------------------------------// 移除map中满足条件的元素//----------------------- ...

  2. Entity Framework 学习初级篇6--EntityClient

    System.Data.EntityClient 命名空间是 实体框架的 .NET Framework 数据提供程序.EntityClient 提供程序使用存储特定的 ADO.NET 数据提供程序类和 ...

  3. C++读取excel特定行列中的数据

    可以通过COM API调用才是正解,不过需要编写COM接口类,Excel对象库的接口太多了……不过可以用工具自动生成. 我最近也在用VC操作Excel,在VC中可以这样做,在任何一个cpp文件中加入下 ...

  4. UI和UE有什么区别呢?

    UCD(以用户为中心的设计)UE(用户体验)UI(用户界面)HCI(人机交互)usability(易用性)

  5. 滑雪(ski)

    滑雪(ski) 题目描述 Michael喜欢滑雪.这并不奇怪,因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你.Michael想知道 ...

  6. Struts2.3.16日志(中)

    Result Configuration --Result 配置 当一个操作类方法完成后,它将返回一个字符串.字符串的值是用来选择一个元素的结果.一个操作映射的结果往往会有一组代表不同的可能的结果.一 ...

  7. 近期用过的Linux口令备份

    最近使用Ubuntu用到的一些口令: rm -rf directory 移除文件夹或者文件touch (create file)mkdirmv(move,rename)chown (change ow ...

  8. 转:web_url函数学习

    web_url语法:        Int Web_url(const char *name, const char * url, <Lists of Attributes>, [EXTR ...

  9. 关于js的几道经典题(作用域、原型链等)自己做的

    1. function test() { var a = 1; setTimeout(function() { alert(a); a = 3; }, 1000); a = 2; setTimeout ...

  10. Python之路:堡垒机实例以及数据库操作

    一.堡垒机前戏 开发堡垒机之前,先学习Python的paramiko模块,该模块基于SSH用于连接远程服务器并执行相关操作. SSHClient 用于连接远程服务器并执行基本命令 基于用户名密码连接: ...