分页查询
来源:互联网 发布:windows rt连接口 编辑:程序博客网 时间:2024/06/06 05:14
<!-- 分页 --> <sql id="paging"> <if test="isPage != null and isPage != '' "> <!-- start 开始页 length 总共显示几条记录( 从 length=start+1开始, 取出length条记录 )--> limit #{start}, #{length} </if> </sql> <!-- 通过这种方式可以避免了where 条件中如果为空的话,sql语句出错 --> <sql id="pageWhere"> <where> <if test="personid != null and personid != '' "> AND personid = #{personid} </if> <if test="personname != null and personname != '' "> AND personname like concat( concat( '%', #{personname} ), '%' ) </if> <if test="personcname != null and personcname != '' "> AND personcname like concat ( concat('%', #{personcname} ), '%' ) </if> <if test="persontelephone != null and persontelephone != '' "> AND persontelephone like concat('%', #{persontelephone}, '%') </if> </where> </sql> <!--在sql语句中 传入的参数parameterType 类型有两种(基本数据类型(int,string,long,Date),复杂数据类型 (类和Map) ) 获取参数的值 基本数据类型: #{参数} 获取参数中的值 复杂数据类型: #{属性名}, map中则是#{key} --> <!-- 在sql语句的返回参数分为2中 ,resultMap (结果集) 和resultType(int, string, long, class) 注意点: 在MyBatis 进行查询映射时,其实查询出来的每个属性都是放在一个对应的Map里面的 其中键是属性名, 值则是其对应的值 --> <!-- 分页查询 --> <select id="selectPerson" parameterType="Person" resultType="Person"> select * from person <include refid="pageWhere"></include> <include refid="paging"></include> </select> <!-- 查询符合条件人员总数量 --> <select id="selectPersonCount" parameterType="Person"> selecte count(personcname) from person <include refid="pageWhere"></include> <!-- 通过加条件语句判断出在输入条件范围内所有的人员数量 分页下面的总数 --> </select>
阅读全文
0 0
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- 分页查询
- Python学习笔记(1)- 安装及变量
- python的requests 模块使用方法
- TCP 是互联网核心协议之一
- C/C++ 计时
- 简单的隔行换色 jq
- 分页查询
- Spring中事务管理
- Python.Numpy学习零碎笔记之便捷函数
- 1122. Hamiltonian Cycle (25)(哈密顿)
- windows系统启用2个以上的mysql服务
- title标签,head部分
- 《From Zero to Hero – 从1000个代码案例中学习人工智能和大数据》课程
- 机器学习学习笔记--反向传播神经网络
- 控制语句