博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mybatis 查询语句(按条件查询)
阅读量:7240 次
发布时间:2019-06-29

本文共 1053 字,大约阅读时间需要 3 分钟。

<select id="getAllDitch" parameterType="xxx.xx.entity.CheckDitch" resultType="xxx.xx.entity.CheckDitch">

select
<include refid="checkDitchColumns"/>
from check_ditch a
<where>
a.status not in (-1)
<if test="generalizeScene != null and generalizeScene != ''">
AND a.generalize_scene like concat('%',#{generalizeScene},'%')
</if>
<if test="useagePerson != null and useagePerson != ''">
AND a.useage_person like concat('%', #{useagePerson},'%')
</if>
<if test="generalizeWay != null and generalizeWay != ''">
AND a.generalize_way = #{generalizeWay}
</if>
<if test="status != null and status != ''">
AND a.status = #{status}
</if>
<if test="startTime != null and startTime != ''">
AND a.create_time >= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND a.create_time &lt;= #{endTime}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.status DESC,a.update_time DESC,a.create_time DESC
</otherwise>
</choose>
</select>

 

切记:<if>标签语句一定要用and

转载地址:http://akfbm.baihongyu.com/

你可能感兴趣的文章
struts2从2.2.3升级到2.3.15.1步骤
查看>>
你所不了解的静态路由特点及配置
查看>>
37、pendingIntent 点击通知栏进入页面
查看>>
TCP为何采用三次握手来建立连接,若采用二次握手可以吗?
查看>>
Jfreet 自动删除生成的图片
查看>>
snmp
查看>>
java笔记----java新建生成用户定义注释
查看>>
批量删除记录时如何实现全选【总结】
查看>>
Thread’s start method and run method
查看>>
使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【二】——使用Repository模式构建数据库访问层...
查看>>
CDN发展史
查看>>
Atitit.研发团队的管理原则---立长不立贤与按资排辈原则
查看>>
UVa 10763 - Foreign Exchange
查看>>
#lspci | grep Eth
查看>>
日订单峰值破40万!58速运订单调度系统架构大解密
查看>>
Objective-C 资源收藏
查看>>
MFC——从实现角度分析微云界面
查看>>
正则 群组 Group
查看>>
An Introduction To The SQLite C/C++ Interface
查看>>
关闭Pycharm拼写检查
查看>>