Sql片断
来源:互联网 发布:环境破坏的事例和数据 编辑:程序博客网 时间:2024/05/16 14:59
将通用的sql语句抽取出来、单独定义,在其它的statement中可以引用sql片段。
通用的sql语句,常用:wher条件、查询列。
<!-- 用户查询条件定义为sql片断
建议对单表的查询条件单独抽取sql片段,提高公用性
注意:不要将where标签放在sql片断
-->
<sqlid="query_user_where">
<!-- test中userCustom.username表示从userQueryVo读取属性值 -->
<iftest="userCustom!=null">
<iftest="userCustom.username!=nulland userCustom.username!=''">
and username like '%${userCustom.username}%'
</if>
<iftest="userCustom.sex!=nulland userCustom.sex!=''">
and sex = #{userCustom.sex}
</if>
</if>
</sql>
<selectid="findUserCount"parameterType="cn.itcast.mybatis.po.UserQueryVo"resultType="int">
select count(*) from user
<!-- where标签相当于where关键字,可以自动去除第一个and -->
<where>
<!-- 引用sql片断,如果sql片断和引用不在同一个mapper必须前边加namespace -->
<includerefid="query_user_where"></include>
</where>
</select>- Sql片断
- MyBatis--动态SQL---sql片断
- 代码片断
- 生活片断
- 文字片断
- SpringActionscript3 片断
- 代码片断
- 代码片断
- 代码片断
- 零散片断
- 打印VO的SQL语句和绑定参数的代码片断
- 常用代码片断
- C#代码片断
- osworkflow descriptor 解析片断
- I2C等程序片断
- 摘录《黑话水浒》片断
- 几个Asp小片断。
- 打印小片断
- 关于c++中的vector
- 博客第一天!
- 程序的编译链接过程
- prim算法
- markdown编辑器用法
- Sql片断
- 【猫厂面试题】——-2016(Web前端)
- LeetCode 75. Sort Colors
- @SuppressWarnings(unused) 、serial与rawtypes等等
- greedy: 55. Jump Game \ 455. Assign Cookies
- 单词积累
- uva 11997K Smallest Sums
- [POJ2777] 统计颜色 - 线段树
- go语言获取数组长度