在mybatis 中使用if else 进行判断的操作

网友投稿 254 2023-02-05

在mybatis 中使用if else 进行判断的操作

我就废话不多说了,大家还是直接看代码吧~

SELECT

i.itemsid

FROM pq_goods_items i

i.personone=#{personone}

AND i.persontwo=#{persontwo}

AND i.color=#{color}

i.personone=#{personone}

AND i.persontwo=#{persontwo}

AND i.color is null

需要注意的是 使用了where标签以后,sql中不在使用where字段来限制条件

如果判断条件有多个 中间用 and 表示并列

补充:mybaits中if 多个test 和 if else 分支支持

mybaits中if 多个test

select

from gene_polymorphism

diag_id = #{conds.diagId,jdbcType=INTEGER}

and chromesome = #{conds.chromesome,jdbcType=VARCHAR}

and start_pos >= #{conds.startPos,jdbcType=BIGINT}

if else分支:

select

from gene_polymorphism

diag_id = #{conds.diagId,jdbcType=INTEGER}

and chromesome = #{conds.chromesome,jdbcType=VARCHAR}

and start_pos >= #{conds.startPos,jdbcType=BIGINT}

and end_pos <= #{conds.endPos,jdbcType=BIGINT}

and (

gene_type like CONCAT('%',CONCAT(#{item,jdbcType=VARCHAR}, '%'))

)

and gene_change like CONCAT('%',CONCAT(#{conds.geneChange,jdbcType=VARCHAR}, '%'))

order by

chromesome asc ,

chromesome desc ,

start_pos asc ,

start_pos desc ,

id desc

limit #{startRow,jdbcType=INTEGER} ,#{pageSize,jdbcType=INTEGER}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:mybatis的动态sql之if test的使用说明
下一篇:Java工作环境的配置与Eclipse的安装过程
相关文章

 发表评论

暂时没有评论,来抢沙发吧~