mybatis if test 相等的情况如何动态拼接sql
2015-08-16 18:29
197 查看
今天程序需要根据前台的传过来的状态判断在数据库里是取 where a>b
还是 a<b 还是 a=0 的情况 搞了一下午最后试了下 在if 里面拼接 #{status}=#{status} 一切ok了
详细代码如下
还是 a<b 还是 a=0 的情况 搞了一下午最后试了下 在if 里面拼接 #{status}=#{status} 一切ok了
详细代码如下
<if test=" status==1"> and inv.security_inventory < inv.actual_inventory and #{status} = #{status} </if> <if test=" status==2"><!-- 缺货--> and inv.security_inventory > inv.actual_inventory and #{status} = #{status} </if> <if test=" status==3"><!-- 无货--> and inv.security_inventory = 0 and #{status} = #{status} </if>
相关文章推荐
- 学数据库钱途怎么样? 学什么数据库好呢?
- 解决PL/SQL Developer 连接oracle 11g 64位中的问题
- Redis命令
- 15、SQL Server 触发器
- mongoDB分片集群配置详解
- 课后作业11--使用SQL语句创建一个数据库
- 检索08- SQL语句中的go与use用法
- memcached监控的几种方法(nagios等)
- MySQL数据库优化之SQL及索引
- 用mysql workbench导出mysql数据库关系图
- Oracle数据库临时总结-1
- MySQL Cluster报错及解决方法(不断更新中)
- SQL性能调整
- 为什么使用 Redis及其产品定位
- SQL实现类似于自动刷新数据的功能
- NoSQL架构实践(三)——以NoSQL为缓存
- opentaps初学习之安装(mysql)
- mysql锁研究系列二(MySQL表级锁的锁模式)
- NoSQL架构实践(二)——以NoSQL为主
- 数据库种类 以及优缺点