where id=#{id}
### 4、if
SELECT * FROM user WHERE 1 = 1
AND position like #{position}
### 5**、choose、when、otherwish**
SELECT * FROM user WHERE 1 = 1
<when test="position != null">
AND position like #{position}
</when>
<when test="department != null and department.name != null">
AND department_name like #{department.name}
</when>
<otherwise>
AND department_name = '公司'
</otherwise>
### 6、foreach
SELECT id,name,age,sex,address,school FROM user u
WHERE id in
<foreach item=“item” index=“index” collection=“list”
open="(" separator="," close=")">
#{item}
当使用可迭代对象或者数组时,index 是当前迭代的次数,item 的值是本次迭代获取的元素。
当使用 Map 对象(或者 Map.Entry 对象的集合)时,index 是键,item 是值。
INSERT INTO
s
c
h
e
m
a
N
a
m
e
.
{schemaName}.
schemaName.{tableName}
<foreach collection="map.keys" item="key" open="(" separator="," close=")">
${key}
</foreach>
VALUES
<foreach collection="map.entrySet()" open="(" separator="," close=")" index="key" item="val">
<choose>
<when test='key.contains("date")'>
to_date(#{val}, 'yyyy-MM-dd HH24:mi:ss')
</when>
<otherwise>
#{val}
</otherwise>
</choose>
</foreach>
### 7、bind
SELECT * FROM user
WHERE dept_id = #{dept}
### 8、连接多数据库
<if test="_databaseId == 'oracle'">
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual
</if>
<if test="_databaseId == 'mysql'">
select now() as Systemtime
</if>
往期精彩内容:
[Java知识体系总结](https://codechina.csdn.net/m0_60958482/java-p7)
[Spring框架总结](https://codechina.csdn.net/m0_60958482/java-p7)
[超详细的springBoot学习笔记](https://codechina.csdn.net/m0_60958482/java-p7)
[常见数据结构与算法整理总结](https://codechina.csdn.net/m0_60958482/java-p7)
[Java设计模式:23种设计模式全面解析](https://codechina.csdn.net/m0_60958482/java-p7)
### 最后
手绘了下图所示的kafka知识大纲流程图(xmind文件不能上传,导出图片展现),但都都可提供源文件给每位爱学习的朋友,**[获取链接:戳这里免费下载](https://codechina.csdn.net/m0_60958482/java-p7)**
![image.png](https://img-blog.csdnimg.cn/img_convert/61513742ecee79ceb1146e70db5c8f91.png)
.csdn.net/m0_60958482/java-p7)
### 最后
手绘了下图所示的kafka知识大纲流程图(xmind文件不能上传,导出图片展现),但都都可提供源文件给每位爱学习的朋友,**[获取链接:戳这里免费下载](https://codechina.csdn.net/m0_60958482/java-p7)**
[外链图片转存中...(img-to9ZTaeL-1630164496681)]
|