MyBatis中相关SQL语句

1.between... and...


    and report_date between #{reportStartDate} AND #{reportEndDate}

2.and   or


	and ( Method like CONCAT('%', #{key ,jdbcType=VARCHAR}, '%')
	or EventCode like CONCAT('%', #{key ,jdbcType=VARCHAR}, '%')
	or EventName like CONCAT('%', #{key ,jdbcType=VARCHAR}, '%')
	)

3.like ---两种写法


          
  
      and report_rule like CONCAT('%',#{reportRule},'%')
             

         

  
      and cust_name like '%' #{custName} '%'
  
  
       and creater like '%' #{creater} '%'
  

完整示例: 

 前端传入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语句只写了

你可能感兴趣的:(sql,mybatis,数据库)