在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. 【android相关】【问题解决】R.java文件丢失

    在进行android开发过程中,有时候,我们会遇到gen文件中R.java丢失的现象.重新build,或者clean工程,close并重新打开Project,但有时也没解决. 这可能是由于不小心把xm ...

  2. hdu 1348 Wall (凸包模板)

    /* 题意: 求得n个点的凸包.然后求与凸包相距l的外圈的周长. 答案为n点的凸包周长加上半径为L的圆的周长 */ # include <stdio.h> # include <ma ...

  3. InputStream写文件出现大量NUL

    写文件大家出现最多的是汉字知码之类的问题,今天不是乱码问题,是出现在大量空字符,用记事本打开是不可见的.如果用NodePad++打开则会显示NUL 问题分题: 刚开始以为是编码问题,试了几个编码发现问 ...

  4. Tabs or Spaces?

    Never mix tabs and spaces. The most popular way of indenting Python is with spaces only. The second- ...

  5. 云解析DNS使用教程

    云解析(Domain. Name System,简称DNS)是一种高可用性.高可扩展的权威DNS服务和DNS管理服务.它的目的是为企业和开发者提供稳定.安全.智能的把网站域名或应用资源转换为计算机用于 ...

  6. 你要相信你所做的一切对一个更美好的世界 Do have faith in what you are doing All for a better world

    http://www.nowamagic.net/librarys/veda/detail/2502 Do have faith in what you are doing. 先不要往下看,试试品尝上 ...

  7. lucene 多索引目录搜索实现方法

    http://akululu.iteye.com/blog/314130 多索引目录就是要在多个索引目录的中进行比较搜索,类似概念在SQL中就是select * from TableA union s ...

  8. SVN环境搭建(2)

    原文地址:http://www.penglig.com/post-73.html TortoiseSVN的使用. 首先打开VisualSVN Server Manager,如图: 可以在窗口的右边看到 ...

  9. svn your working copy appears to be locked run cleanup to amend the situation

    cleanup  则解决

  10. c++opencv项目移植到Android(Mat—》IplImage*)

    近期将PC机上的行人检測的C++项目移植到Android平台遇到非常多的问题.因此,记录一些重点. 1. 最好能够參照Opencv sample 里面的mix-processing. 2. 数据结构的 ...