首页 > 数据库技术 > 详细

mybatis if test 相等的情况如何动态拼接sql

时间:2015-08-16 19:51:59      阅读:962      评论:0      收藏:0      [点我收藏+]

今天程序需要根据前台的传过来的状态判断在数据库里是取 where a>b 

还是 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>

版权声明:本文为博主原创文章,未经博主允许不得转载。

mybatis if test 相等的情况如何动态拼接sql

原文:http://blog.csdn.net/majun_guang/article/details/47704469

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!