mybatis的动态sql标签
2017-05-16 09:46
393 查看
mybatis的动态sql
标签
1. <if test="条件成立">
拼接的sql
</if>
2. <where>
<if test="条件 and 条件">
and ...
</if>
<if test="条件 and 条件">
and ...
</if>
</wnere>
说明:where标签在最后会将第一个条件的"and"给去掉,以防止sql拼写异常
3. <set>
<if test="条件">
...,
</if>
<if test="条件">
...,
</if>
</set>
说明:set标签在最后会将最后一个set的“,”给去掉,以防止sql拼写异常
4. <choose>
<when test="条件">
。。。
</when>
<otherwise>
。。。
</otherwise>
</choose>
5.
说明foreach循环可以便来List,Set,Map集合,当为Map集合时自定义为key或value,默认为Value
标签
1. <if test="条件成立">
拼接的sql
</if>
2. <where>
<if test="条件 and 条件">
and ...
</if>
<if test="条件 and 条件">
and ...
</if>
</wnere>
说明:where标签在最后会将第一个条件的"and"给去掉,以防止sql拼写异常
3. <set>
<if test="条件">
...,
</if>
<if test="条件">
...,
</if>
</set>
说明:set标签在最后会将最后一个set的“,”给去掉,以防止sql拼写异常
4. <choose>
<when test="条件">
。。。
</when>
<otherwise>
。。。
</otherwise>
</choose>
5.
<select id="selectById" resultType="com.zyj.test.User"> select <include refid="usercolumn"></include> from tb_user <where> id in <foreach collection="ids" open="(" close=")" item="userid" separator=","> #{userid} </foreach> </where> </select>
说明foreach循环可以便来List,Set,Map集合,当为Map集合时自定义为key或value,默认为Value
相关文章推荐
- 详解MyBatis的getMapper()接口、resultMap标签、Alias别名、 尽量提取sql列、动态操作
- MyBatis的动态SQL查询常用几种标签
- mybatis中动态sql标签之if trim
- mybatis动态sql中的trim标签的使用
- mybatis实战之动态sql标签学习
- mybatis动态sql中where标签的使用
- mybatis动态sql中的trim标签的使用
- mybatis动态sql中的trim标签的使用
- mybatis动态sql中的trim标签的使用
- MyBatis--动态SQL---where标签
- MyBatis--动态SQL---foreach标签--List
- mybatis动态SQL标签的用法
- MyBatis动态SQL中trim标签的使用
- mybatis动态sql中的trim标签的使用
- mybatis动态sql中的trim标签的使用
- MyBatis动态SQL标签用法实例详解
- mybatis动态查询 sql标签和include标签的使用
- MyBatis动态SQL中trim标签的运用
- mybatis的动态SQL(一)if标签的使用
- Mybatis动态SQL单一基础类型参数用if标签