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. ...
随机推荐
- leveldb性能分析
Leveldb是一个google实现的非常高效的kv数据库,目前的版本1.2能够支持billion级别的数据量了. 在这个数量级别下还有着非常高的性能,主要归功于它的良好的设计.特别是LSM算法. 那 ...
- sql语句删除由于无主键导致完全重复的数据方法
sql语句删除由于无主键导致完全重复的数据方法 select distinct * into #Tmp from t_column drop table t_column select * into ...
- jquery has deprecated synchronous XMLHTTPRequest
Like many others, my website is using jquery. When I open the developer tools, I see a warning that ...
- 12C 连接方式和 Oracle Easy Connect Naming method
1.12C 连接方式 PDB is not an instance, so using SID in the connection string will not work. When the dat ...
- mybatis与spring整合(基于配置文件)
本文主要介绍了如何将mybatis和spring整合在一起使用,本人使用的是mybatis3.05 + spring3.1.0M2 ,使用dbcp作为数据库连接池. 1.编写数据访问接口(UserDa ...
- 如何做好移动安全(梆梆加固后的APK破解提取dex)
智能手机的普及将移动互联网的发展推到了一个让所有人都为之兴奋的高度,我想即使是以商业眼光见长的“苹果教父”乔布斯也不会料想到短短几年时间,智能手 机就已经成为了所有人离不开的商业产品,各种商业应用层出 ...
- 需要注意的subList方法!和substring是不一样的!从源码解释他们的不同。
很多时候我们截取字符串用的是substring方法,很自然用着,但是对于列表的截取时很多时候就用得很少,但是其实他们是很不一样的,具体哪里不一样呢? package main; import java ...
- 如何把mysql的ID归0?
如何把mysql的ID归0 可以归0的,truncate table + 表名 就行了
- Eclipse开发Maven项目提示:程序包org.junit不存在解决方案
原因: 个人考虑产生此错误的原因是因为Eclipse中对于测试和开发的鉴定不明?Intellij中没有错误,因为Intellij对项目的管理就是同Maven结构的. 解决方案: 原来的junit的sc ...
- php正则表达式手册
(http://deerchao.net/tutorials/regex/regex.htm)转载:作者:deerchao php的正则表达式很强大,学好了的确有很大的用处,但是正则表达式的规则很繁琐 ...