mybatis常用sql拼写
来源:互联网 发布:第二磨牙长歪了 知乎 编辑:程序博客网 时间:2024/05/22 02:13
<mapper namespace = "com.company.people">
<select id="findList" resultType="People">
select a.name as name, a.age as age
from people a
<where>
<if test="title !=null and title!='' and title !='1'.toString()">
a.title like
<if test="dbName=='oracle'"> '%'||#{title}||'%'</if>
<if test="dbName=='mssql'"> '%'+#{title}+'%'</if>
<if test="dbName=='mysql'"> concat('%',#{title},'%')</if>
</if>
</where>
<choose>
<when test="page !=null and page.orderBy !=null and page.OrderBy !=''">
order by ${page.orderBy}
</when>
<otherwise>
order by a.update_date desc
</otherwise>
</choose>
</select>
<insert id="insert">
insert into people(
id,
name,
age,
del_flag
)values(
#{id},
#{name},
#{age},
#{del_flag}
)
<insert>
<update id="update">
update people set
name=#{name},
age=#{age}
where id=#{id}
</update>
一次插入一个list
<insert id="saveAllPeople" parameterType="List">
insert into people(
id,
name,
age,
del_flag
)
<if test="list.get(0).dbName=='oracle'">
<foreach collection="list" item="e" separator="union all">
select
#{e.id},
#{e.name},
#{e.age},
#{e.del_flag}
</foreach>
</if>
<if test="list.get(0).dbName=='mssql' or list.get(0).dbName=='mysql'">
valuse
<foreach collection="list" item="e" open="" sparator="," close="">
(
#{e.id},
#{e.name},
#{e.age},
#{e.del_flag}
)
</foreach>
</if>
</insert>
- mybatis常用sql拼写
- mybatis @Select注解中如何拼写动态sql
- Mybatis中的常用sql
- MyBatis常用动态SQL
- mybatis常用sql
- Mybatis中执行String类型的自己拼写的sql,不执行配置文件中的sql
- Mybatis中执行String类型的自己拼写的sql,不执行配置文件中的sql
- Mybatis的动态sql详解,区别于传统的sql拼写
- SQL的拼写
- mybatis中_parameter使用和常用sql
- Mybatis常用sql语句xml配置
- mybatis生成动态sql的常用标签
- mybatis中_parameter使用和常用sql
- mybatis中动态sql常用的标签
- mybatis中动态sql常用的标签
- MyBatis常用SQL语句整理笔记
- mybatis中动态sql常用的标签
- mybatis中动态sql常用的标签
- POJ
- js经典小案例之倒计时
- 深海探险 51Nod
- 几种Boost算法的比较(Discrete AdaBoost, Real AdaBoost, LogitBoost, Gentle Adaboost)
- 「python」函数返回多个值、缺省参数、不定长参数、引用参数
- mybatis常用sql拼写
- 静态化Freemarker的标签
- Java NIO使用及原理分析 (四)
- 51nod 1287 加农炮
- 初学Unity3D Shader之Cube纹理坐标探索
- leetcode 643. Maximum Average Subarray I
- ECMAScript的一些学习网站
- Office2013出现”停止工作“问题的解决
- [LintCode 200] 最长回文字符串(Python)