在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>

 
 

ibatis 大于等于小于等于的写法的更多相关文章

  1. mybatis中大于等于小于等于的写法

    标准写法如下: 第一种写法(1): 原符号 < <= > >= & ' "替换符号 < <= > >= & &apos ...

  2. MySQL中大于等于小于等于的写法

    由于在mybatis框架的xml中<= , >=解析会出现问题,编译报错,所以需要转译 第一种写法: 原符号 < <= > >= & ' " 替换 ...

  3. mybatis大于等于小于等于的写法

    第一种写法(1): 原符号 < <= > >= & ' " 替换符号 < <= > >= & &apos; " ...

  4. 【新】mybatis中大于等于小于等于的两种常用写法

    mybatis中大于等于小于等于的写法 原符号 < <= > >= & ' " 替换符号 < <= > >= & &a ...

  5. mybatis中大于等于、小于等于的写法

    在xml格式中,常常会遇到xml解析sql时候出错,这个时候需要用其他符号来表示.在mybatis中会遇到,需要做如下的转换:

  6. mybatis中大于等于小于的写法

    第一种写法(1): 原符号 < <= > >= & ' "替换符号 < <= > >= & &apos; " ...

  7. sql中大于等于小于的写法

    由于在mybatis框架的xml中<= , >=解析会出现问题,编译报错,所以需要转译第一种写法: 原符号 < <= > >= & ' "替换符号 ...

  8. iBatis 中 Like 的写法实现模糊查询

    iBatis 开发指南告诉我们,当 Person 对象的 name 属性不为 null 时启用 name 查询条件在映射文件 person.xml 中的配置为 <select id=" ...

  9. IBATIS sql 小于(<) 写法 特殊符号写法

    SELECT * FROM XXX where  column1  <![CDATA [ < 100 ]]> ************************************ ...

随机推荐

  1. 我的superui开源后台bootstrap开发框架

    我的superui开源后台bootstrap开发框架:http://git.oschina.net/tzhsweet/superui

  2. 进程资源和进程状态 TASK_RUNNING TASK_INTERRUPTIBLE TASK_UNINTERRUPTIBLE

    摘要:本文主要介绍进程资源和进程状态.进程资源由两部分组成:内核空间进程资源以及用户空间进程资源.进程状态,就绪/执行状态.等待状态(能够被中断打断).等待状态(不能够被中断打断).停止状态和僵死状态 ...

  3. jQuery 文档操作 - prependTo() ,appendTo()方法

    其他jquery文档操作方法:http://www.w3school.com.cn/jquery/jquery_ref_manipulation.asp jQuery 参考手册 - 文档操作 appe ...

  4. Atitit.自定义jdbc驱动  支持jsql

    Atitit.自定义jdbc驱动  支持jsql 1. 为什么需要自定义驱动1 1.1. 透明分库分表1 1.2. 自定义数据库的接口.比如大数据文档文件类型的数据库,数据存储引擎2 2. 整个文章分 ...

  5. Django中ORM介绍和字段参数

    Object Relational Mapping(ORM) ORM介绍 ORM概念 对象关系映射(Object Relational Mapping,简称ORM)模式是一种为了解决面向对象与关系数据 ...

  6. 美团HD(8)-利用NSPredicate匹配搜索结果

    监听文本框改变: DJSelectCityViewController.m /** 当searchBar内的文字发生改变时调用此方法 */ - (void)searchBar:(UISearchBar ...

  7. 74. First Bad Version 【medium】

    74. First Bad Version [medium] The code base version is an integer start from 1 to n. One day, someo ...

  8. boost中全局命名锁的使用

    使用头文件相对位置为:boost/interprocess/sync/named_mutex.hpp 在程序中使用 boost::interprocess::named_mutex g_namedmu ...

  9. is char signed or unsigned?

    工作这么多年,一直认为char是有符号的,而事实上gcc和vs默认也是有符号,但是c规范里实际并没有指明char是有符号还是无符号,所以char比较特殊, char signed char unsig ...

  10. TP find() 查找

    如果用了find()进行查找数据.那么那么获取到这条对象的则是用find查找出的这条对象. 如果: $obj=$this->where('id'=>$id)->find(); 那么可 ...