av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁(yè)/技術(shù)文章
文章詳情頁(yè)

在mybatis 中使用if else 進(jìn)行判斷的操作

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

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

<!-- 查詢物品的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標(biāo)簽以后,sql中不在使用where字段來(lái)限制條件

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

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

補(bǔ)充:mybaits中if 多個(gè)test 和 if else 分支支持

mybaits中if 多個(gè)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>

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教。

相關(guān)文章:
主站蜘蛛池模板: 特黄一级| 一区二区三区欧美 | 一本久久a久久精品亚洲 | www.五月天婷婷.com | 久久久精品综合 | www.国产| 国产精品久久久久久久久久免费看 | 欧美13videosex性极品 | 久久99精品国产麻豆婷婷 | 精品一二三区 | 免费网站在线 | 美日韩一区二区 | 久久久久亚洲 | 日韩在线欧美 | av一区在线 | a在线视频| 高清av一区 | 久久久精品天堂 | 欧美韩一区二区 | 国产 欧美 日韩 一区 | 一区二区三区欧美在线 | 亚洲视频三| 亚洲精品视频在线观看视频 | 综合二区 | 欧美成视频 | 九七午夜剧场福利写真 | jizz在线免费观看 | 国产精品久久久久久久久久久久久久 | 操人视频在线观看 | 午夜视频大全 | 欧美在线视频观看 | 久久99精品久久久久久青青日本 | 久久久久久久一区 | 免费观看一级特黄欧美大片 | 一区二区三区在线观看视频 | 国产激情视频在线 | 欧美11一13sex性hd | 亚洲一区中文 | 中文字幕av一区二区三区 | 国产美女在线看 | 中文字幕人成乱码在线观看 |