最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

MyBatis中執(zhí)行相關(guān)SQL語句的方法

 更新時間:2023年08月16日 15:53:42   作者:weixin_46949892  
本文主要介紹了MyBatis中執(zhí)行相關(guān)SQL語句的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

1.between... and...

<if test="(reportStartDate != null and reportStartDate != '') || (reportEndDate != null and reportEndDate != '')">
    and report_date between #{reportStartDate} AND #{reportEndDate}
</if>

2.and   or

<if test="method != null">
    and ( Method like CONCAT('%', #{key ,jdbcType=VARCHAR}, '%')
    or EventCode like CONCAT('%', #{key ,jdbcType=VARCHAR}, '%')
    or EventName like CONCAT('%', #{key ,jdbcType=VARCHAR}, '%')
    )
</if>

3.like ---兩種寫法

<!--第一種寫法-->
<where>          
  <if test="reportRule != null and reportRule != ''">
      and report_rule like CONCAT('%',#{reportRule},'%')
  </if>           
</where>
<!--第二種寫法-->         
<where>
  <if test="custName != null and custName != ''">
      and cust_name like '%' #{custName} '%'
  </if>
  <if test="creater != null and creater != ''">
       and creater like '%' #{creater} '%'
  </if>
</where>

完整示例: 

<select id="findByQueryIds"  parameterType="string" resultType="java.lang.Integer">
    select id from t_monitor_suspicion_custom
    <where>
      <if test="(reportStartDate != null and reportStartDate != '') || (reportEndDate != null and reportEndDate != '')">
         and report_date between #{reportStartDate} AND #{reportEndDate}
      </if>
      <if test="reportRule != null and reportRule != ''">
         and report_rule like CONCAT('%',#{reportRule},'%')
      </if>
      <if test="custNo != null and custNo != ''">
         and cust_no like CONCAT('%',#{custNo},'%')
      </if>
      <if test="custName != null and custName != ''">
          and cust_name like CONCAT('%',#{custName},'%')
      </if>
      <if test="customType != null and customType != ''">
          and custom_type = #{customType}
      </if>
   </where>
   and (suspicion_status = #{value} or suspicion_status = #{value1})
</select>

 前端傳入cust_no為1019,后端實際查詢語句

[zl-aml-admin] DEBUG 2023-08-15 10:44:14.514 [http-nio-8081-exec-20] com.zlpay.modules.monitor.dao.SuspicionCustomDao.findByQueryIds [BaseJdbcLogger.java:137] - ==>  Preparing: select id from t_monitor_suspicion_custom WHERE cust_no like CONCAT('%',?,'%') and (suspicion_status = ? or suspicion_status = ?)
[zl-aml-admin] DEBUG 2023-08-15 10:44:14.516 [http-nio-8081-exec-20] com.zlpay.modules.monitor.dao.SuspicionCustomDao.findByQueryIds [BaseJdbcLogger.java:137] - ==> Parameters: 1019(String), 0(String), 3(String)
[zl-aml-admin] DEBUG 2023-08-15 10:44:14.519 [http-nio-8081-exec-20] com.zlpay.modules.monitor.dao.SuspicionCustomDao.findByQueryIds [BaseJdbcLogger.java:137] - <==      Total: 1

注意:由于一開始where語句只寫了 <if test="reportRule != null>沒有寫reportRule != ''" ,導(dǎo)致查詢結(jié)果出錯,所以我們?nèi)绻玫絼討B(tài)查詢的話,一定要搞清楚前端傳的是空值還是null值,如果不確定的話,就都判斷一下<if test="reportRule != null and reportRule != ''">

到此這篇關(guān)于MyBatis中執(zhí)行相關(guān)SQL語句的方法的文章就介紹到這了,更多相關(guān)MyBatis 執(zhí)行SQL語句內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Java日常練習(xí)題,每天進步一點點(57)

    Java日常練習(xí)題,每天進步一點點(57)

    下面小編就為大家?guī)硪黄狫ava基礎(chǔ)的幾道練習(xí)題(分享)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧,希望可以幫到你
    2021-08-08
  • java實現(xiàn)最短路徑算法之Dijkstra算法

    java實現(xiàn)最短路徑算法之Dijkstra算法

    這篇文章主要介紹了java實現(xiàn)最短路徑算法之Dijkstra算法, Dijkstra算法是最短路徑算法中為人熟知的一種,是單起點全路徑算法,有興趣的可以了解一下
    2017-10-10
  • Spring Boot 快速集成 Redis的方法

    Spring Boot 快速集成 Redis的方法

    這篇文章主要介紹了Spring Boot 如何快速集成 Redis,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-07-07
  • java多線程編程實現(xiàn)下雪效果

    java多線程編程實現(xiàn)下雪效果

    這篇文章主要介紹了java多線程編程實現(xiàn)下雪效果的相關(guān)資料,需要的朋友可以參考下
    2015-11-11
  • SpringBoot環(huán)境屬性占位符解析和類型轉(zhuǎn)換方式

    SpringBoot環(huán)境屬性占位符解析和類型轉(zhuǎn)換方式

    這篇文章主要介紹了SpringBoot環(huán)境屬性占位符解析和類型轉(zhuǎn)換方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-11-11
  • java中static關(guān)鍵字用法詳解

    java中static關(guān)鍵字用法詳解

    這篇文章主要為大家詳細(xì)介紹了java中static關(guān)鍵字的用法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • java鏈表的常見簡單面試算法題詳解

    java鏈表的常見簡單面試算法題詳解

    文章總結(jié):本文主要介紹了單鏈表的基本操作,包括頭插法、尾插法、鏈表翻轉(zhuǎn)、鏈表成環(huán)判斷、成環(huán)位置判斷、成環(huán)長度判斷,以及有序鏈表的合并,通過實例和代碼示例,詳細(xì)講解了每種操作的原理和實現(xiàn)方法
    2025-01-01
  • Java中@DateTimeFormat @JsonFormat失效原因及測試填坑

    Java中@DateTimeFormat @JsonFormat失效原因及測試填坑

    本文主要介紹了Java中@DateTimeFormat @JsonFormat失效原因及測試填坑,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-06-06
  • springboot @RequiredArgsConstructor的概念與使用方式

    springboot @RequiredArgsConstructor的概念與使用方式

    這篇文章主要介紹了springboot @RequiredArgsConstructor的概念與使用方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-09-09
  • Java9新特性對HTTP2協(xié)議支持與非阻塞HTTP?API

    Java9新特性對HTTP2協(xié)議支持與非阻塞HTTP?API

    這篇文章主要為大家介紹了Java9新特性對HTTP2協(xié)議的支持與非阻塞HTTP?API,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-03-03

最新評論

屏边| 道孚县| 饶平县| 晋宁县| 三原县| 密云县| 伊金霍洛旗| 崇州市| 安多县| 孝义市| 临汾市| 东乌珠穆沁旗| 韩城市| 东乡族自治县| 临桂县| 玛曲县| 洛隆县| 隆回县| 株洲市| 茂名市| 永仁县| 东至县| 中宁县| 万荣县| 苏尼特右旗| 会同县| 枝江市| 四会市| 体育| 松桃| 曲靖市| 英超| 贵溪市| 松原市| 平舆县| 武平县| 金寨县| 汪清县| 翁源县| 温州市| 梅州市|