zoukankan      html  css  js  c++  java
  • ibatis 大于等于小于等于的写法

    在ibatis的sql语句xml配置文件中,写sql语句会经常用到大于等于小于等于等等符号。网上搜罗了一些写法,大致有3种:

    1. 其实就是xml特殊符号,转义的方式。 
      &lt; < 
      &gt; > 
      &lt;&gt; <> 
      &amp; & 
      &apos; ’ 
      &quot; ” 
      比如: 
      select (case when (UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(ur.offline_time)-5*60*1000)&gt;0 then '1' else '0' end) as offline_flag from ……

    2. 使用<![CDATA[ sql语句]]>符号进行说明,将此类符号不进行解析 。 
      比如: 
      <isEqual property="offline_flag" compareValue="0"> 
      and <![CDATA[((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(ur.offline_time)-5*60*1000)<=0 or u.record_id=0)]]> 
      </isEqual>

    3. 如果是参数字段,可以用ibatis的语法。 
      <isEqual> 相等。 
      <isNotEqual> 不等。 
      <isGreaterThan> 大于 
      <isGreaterEqual> 大于等于 
      <isLessThan> 小于 
      <isLessEqual> 小于等于
       
      比如: 
      <isNotEmpty prepend="AND" property="username"> 
      u.username like '%$username$%' 
      </isNotEmpty> 
      <isNotEmpty prepend="AND" property="location"> 
      concat(u.country,u.province,u.city) like '%$location$%' 
      </isNotEmpty> 
      <isEqual property="offline_flag" compareValue="1"> 
      and (UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(ur.offline_time)-5*60*1000)&gt;0 
      </isEqual> 
      <isEqual property="offline_flag" compareValue="0"> 
      and <![CDATA[((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(ur.offline_time)-5*60*1000)<=0 or u.record_id=0)]]> 
      </isEqual> 
      <!-- sort --> 
      <isEqual property="sort_onlinetime" compareValue="asc"> 
      order by u.online_time asc 
      </isEqual> 
      <isEqual property="sort_onlinetime" compareValue="desc"> 
      order by u.online_time desc 
      </isEqual> 
      <isEqual property="sort_registtime" compareValue="asc"> 
      order by u.register_time asc 
      </isEqual> 
      <isEqual property="sort_registtime" compareValue="desc"> 
      order by u.register_time desc 
      </isEqual> 
      <isEqual property="sort_appversion" compareValue="asc"> 
      order by u.app_version asc 
      </isEqual> 
      <isEqual property="sort_appversion" compareValue="desc"> 
      order by u.app_version desc 
      </isEqual>

     
     
  • 相关阅读:
    【rust】Rust 的构建系统和包管理工具Cargo认识并初步使用(2)
    【rust】rust安装,运行第一个Rust 程序 (1)
    linux 双网卡桥接,实现网卡流量镜像与转发
    【原创】使用golang访问windows telnet服务器
    使用centos 7安装conpot
    用Redis作Mysql数据库缓存
    python解析处理snmp回显----snmp
    snmp自定义OID与文件下载----服务器端配置
    golang map输出排序
    计算机组成原理---第1章 计算机系统概述
  • 原文地址:https://www.cnblogs.com/remember-forget/p/7372157.html
Copyright © 2011-2022 走看看