国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

在mybatis 中使用if else 進行判斷的操作

瀏覽:4日期:2023-10-20 08:57:43

我就廢話不多說了,大家還是直接看代碼吧~

<!-- 查詢物品的id --><select parameterType='pd' resultType='java.lang.Integer'>SELECTi.itemsidFROM pq_goods_items i<where> <!--方式一使用choose的方式查詢--> <!-- <choose> <when test='parentId !=0 '>parentTypeId=#{parentId}</when> <when test='parentId==0'>parentTypeId is null</when> </choose> --> <!--方式二使用if的方式查詢--> <if test='color!=null'> i.personone=#{personone}AND i.persontwo=#{persontwo} AND i.color=#{color} </if> <if test='color==null'> i.personone=#{personone}AND i.persontwo=#{persontwo} AND i.color is null </if> </where> </select>

需要注意的是 使用了where標簽以后,sql中不在使用where字段來限制條件

如果判斷條件有多個 中間用 and 表示并列

<if test='color!=null and personone!=null'>

補充:mybaits中if 多個test 和 if else 分支支持

mybaits中if 多個test

<select parameterType='map' resultMap='BaseResultMap'> select <include refid='Base_Column_List' /> from gene_polymorphism <where> diag_id = #{conds.diagId,jdbcType=INTEGER} <if test='conds.chromesome!=null and conds.chromesome!=’’'> and chromesome = #{conds.chromesome,jdbcType=VARCHAR} </if> <if test='conds.startPos!=null'> and start_pos &gt;= #{conds.startPos,jdbcType=BIGINT} </if> </where></select>if else分支:

<select parameterType='map' resultMap='BaseResultMap'> select <include refid='Base_Column_List' /> from gene_polymorphism <where> diag_id = #{conds.diagId,jdbcType=INTEGER} <if test='conds.chromesome!=null'> and chromesome = #{conds.chromesome,jdbcType=VARCHAR} </if> <if test='conds.startPos!=null'> and start_pos &gt;= #{conds.startPos,jdbcType=BIGINT} </if> <if test='conds.endPos!=null'> and end_pos &lt;= #{conds.endPos,jdbcType=BIGINT} </if> <if test='conds.geneTypes!=null'> <!--and gene_type in--> <!--<foreach collection='conds.geneTypes' open='(' close=')' item='item' separator=',' >--> <!--#{item,jdbcType=VARCHAR}--> <!--</foreach>--> and ( <foreach collection='conds.geneTypes' item='item' separator='or'> gene_type like CONCAT(’%’,CONCAT(#{item,jdbcType=VARCHAR}, ’%’)) </foreach> ) </if> <if test='conds.geneChange!=null'> and gene_change like CONCAT(’%’,CONCAT(#{conds.geneChange,jdbcType=VARCHAR}, ’%’)) </if> </where> order by <trim suffixOverrides=','> <choose> <when test='conds.chromesomeSort!=null and conds.chromesomeSort==’asc’'> chromesome asc , </when> <when test='conds.chromesomeSort!=null and conds.chromesomeSort==’desc’'> chromesome desc , </when> </choose> <choose> <when test='conds.startPosSort!=null and conds.startPosSort==’asc’'> start_pos asc , </when> <when test='conds.startPosSort!=null and conds.startPosSort==’desc’'> start_pos desc , </when> <otherwise> id desc </otherwise> </choose> </trim> limit #{startRow,jdbcType=INTEGER} ,#{pageSize,jdbcType=INTEGER} <!-- order by id desc limit #{startRow,jdbcType=INTEGER} ,#{pageSize,jdbcType=INTEGER} --> </select>

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持好吧啦網。如有錯誤或未考慮完全的地方,望不吝賜教。

標簽: Mybatis 數據庫
相關文章:
主站蜘蛛池模板: 久在线观看视频 | 免费欧美在线视频 | 在线视频 自拍 | www.夜夜骑.com | 亚洲 欧美 在线观看 | 全部免费国产潢色一级 | 成年女人免费又黄又爽视频 | 亚欧毛片 | 亚洲欧美18v中文字幕高清 | 韩国免费毛片在线看 | 农村三级孕妇视频在线 | 一级特黄色毛片免费看 | 日韩亚洲综合精品国产 | 亚洲免费不卡 | 亚洲系列第一页 | 日本高清色视频www 日本高清在线精品一区二区三区 | 中日韩一级片 | 亚洲成a人片在线v观看 | 做爰成人五级在线视频| 欧美综合在线视频 | 国产毛片久久久久久国产毛片 | 国产在线高清视频 | 日产一区两区三区 | 欧美韩国日本一区 | 久热久草| 成年女人看片免费视频频 | 亚洲国产专区 | 久草视频手机在线观看 | 香蕉成人 | 久久精品免视看国产明星 | 国产成人精品精品欧美 | 亚洲性xx| 狠狠综合久久久综合 | 在线免费国产 | 色视频网站大全免费 | 国产精品麻豆一区二区三区v视界 | 亚洲图片视频在线 | 亚洲人成在线免费观看 | 精品久久久久久综合网 | 91久久香蕉国产线看观看软件 | 69中国xxxxxxxx18|