Mybatis中常见的SQL DML
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的更多相关文章
- 【mybatis深度历险系列】mybatis中的动态sql
最近一直做项目,博文很长时间没有更新了,今天抽空,学习了一下mybatis,并且总结一下.在前面的博文中,小编主要简单的介绍了mybatis中的输入和输出映射,并且通过demo简单的介绍了输入映射和输 ...
- mybatis中的动态SQL
在实际开发中,数据库的查询很难一蹴而就,我们往往要根据各种不同的场景拼接出不同的SQL语句,这无疑是一项复杂的工作,我们在使用mybatis时,mybatis给我们提供了动态SQL,可以让我们根据具体 ...
- 6.Mybatis中的动态Sql和Sql片段(Mybatis的一个核心)
动态Sql是Mybatis的核心,就是对我们的sql语句进行灵活的操作,他可以通过表达式,对sql语句进行判断,然后对其进行灵活的拼接和组装.可以简单的说成Mybatis中可以动态去的判断需不需要某些 ...
- Mybatis中常用的SQL
1.BaseResultMap <resultMap id="BaseResultMap" type="com.stylefeng.guns.common.pers ...
- SSM-MyBatis-05:Mybatis中别名,sql片段和模糊查询加getMapper
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 简单概述一下本讲 别名,sql片段简单写一下,模糊查询多写一点 一.别名 <typeAliases> ...
- mybatis中常见的问题总结
如下所有举例基于springboot+mybatis项目中,SSH使用mybatis的写法也一样,只是形式不同而已 问题1.org.apache.ibatis.binding.BindingExcep ...
- mybatis中的动态SQL语句
有时候,静态的SQL语句并不能满足应用程序的需求.我们可以根据一些条件,来动态地构建 SQL语句. 例如,在Web应用程序中,有可能有一些搜索界面,需要输入一个或多个选项,然后根据这些已选择的条件去执 ...
- mybatis中的动态SQL(IF Chooes When Where Set ForEach SQL片段)
mapper: public interface BlogMapper { List<Blog> getBlogByIF(Map map); } IF <select id=&quo ...
- mybatis中设置打印sql语句application.yml
在application.yml配置文件中,找到数据源设置,添加: mybatis: configuration: log-impl:org.apache.ibatis.logging.stdout. ...
随机推荐
- Eclipse中代码提示框的背景色修改
Preferences->General->Appearance->Colors and Fonts 修改Basic中的Content Assist backgroud color[ ...
- emacs redo
c / c/ cg c/ cg c/ tramp: /sudo::/usr/
- vm lxc
taxonomy, 有4种: 进程虚拟机:1.相同指令集(wine),2.不同指令集(java)系统虚拟机:3.相同指令集(kvm),4.不同指令集(qemu) 第4种又可分为直接运行于硬件之上(xe ...
- MyEclipse8.5 无法安装ADT解决办法
打开MYECLIPSE.点击菜单栏的help ->my eclipse configure center .然后add site 指向 https://dl-ssl.google.com/an ...
- article标签
<html><head lang="en"> <meta charset="UTF-8"> <title>富士康 ...
- 贝塞尔曲线 & CAShapeLayer & Stroke 动画 浅谈
转载自:http://46aae4d1e2371e4aa769798941cef698.devproxy.yunshipei.com/qiaoqiaoqiao2014/article/details/ ...
- HDU 1317(Floyd判断连通性+spfa判断正环)
XYZZY Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- 算法录 之 BFS和DFS
说一下BFS和DFS,这是个比较重要的概念,是很多很多算法的基础. 不过在说这个之前需要先说一下图和树,当然这里的图不是自拍的图片了,树也不是能结苹果的树了.这里要说的是图论和数学里面的概念. 以上概 ...
- WordPress主题制作第二天
<?php if(have_posts()): while(have_posts()): the_post(); <!-- the_title(); the_permalink(); th ...
- Struts2的整体回顾(Action, 拦截器, 值栈, OGNL表示式, ModelDriven)
ValueStack里有map(request, session, attr, parameters)和对象栈. Map调用的方法: ActionContext.getContext().put(k, ...