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

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

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

瀏覽:2日期: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 數據庫
相關文章:
主站蜘蛛池模板: 九色自拍视频 | 性夜黄a爽爽免费视频国产 性夜影院爽黄a爽免费看网站 | 亚洲午夜片 | 日本一区毛片免费观看 | 日本在线观看免费视频 | 免费国产成人高清在线观看不卡 | 久久视频精品36线视频在线观看 | 亚洲成人一区 | 99在线视频免费 | 香蕉在线观看999 | 久久九九精品一区二区 | 久久99热久久精品91 | 91福利网| 免费一级视频在线播放 | 日本精品一区二区三区在线视频 | 香蕉久久一区二区不卡无毒影院 | 黄色成人在线观看 | 久久好看视频 | 国产精品99久久久久久小说 | 国产情侣真实露脸在线最新 | 成 人 黄 色 视频 免费观看 | hd欧美xxx欧美极品hd | 中文字幕二区 | 99精品视频在线免费观看 | 国产精品_国产精品_国产精品 | 可以看毛片的网站 | 成人一级免费视频 | 岬奈一区二区中文字幕 | 久久久久久亚洲精品中文字幕 | 韩国福利影视一区二区三区 | 在线观看免费亚洲 | 免费国产高清精品一区在线 | 我想看三级特黄 | 国产精品v在线播放观看 | 国产特黄特色的大片观看免费视频 | 亚洲国产精品综合久久久 | 美女被男人桶到嗷嗷叫爽网站 | 国产一区二区三区免费在线视频 | 2021精品国产品免费观看 | 亚洲偷| 极品美女一级毛片 |