SQL时间段查询、分页、in字符串正则拆分

1、SQL时间段数据查询:
因为这个是xml格式的,所以不允许出现类似“>”这样的字符,但是都可以使用符号进行说明,将此类符号不进行解析
你的可以写成这个:
mapper文件示例代码<![CDATA[ when min(starttime)<='12:00' and max(endtime)<='12:00' ]]>
&gt; >
&lt;&gt; <>
&amp; &
&apos; '
&quot; "
示例:
select to_date(to_char(tf.created_time,'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss') from t_ff_rt_workitem tf where to_date(to_char(tf.created_time,'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss')<=to_date('2012-05-19','yyyy-mm-dd hh24:mi:ss')

2、SQL分页
SELECT * FROM ( SELECT A.*, ROWNUM RN FROM (SELECT * FROM ZXZC_PRE_LOG) A WHERE ROWNUM <= 20 ) WHERE RN >= 11>
<if test="params.repayDateBegin!=null and params.repayDateBegin!=''">
<![CDATA[and to_date(to_char(t.CONFIRM_BANKER_DATE,'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss')>=to_date(#{params.repayDateBegin,jdbcType=VARCHAR},'yyyy-mm-dd hh24:mi:ss') ]]>
</if>
<if test="params.repayDateEnd!=null and params.repayDateEnd!=''">
<![CDATA[and to_date(to_char(t.CONFIRM_BANKER_DATE,'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss')<=to_date(#{params.repayDateEnd,jdbcType=VARCHAR},'yyyy-mm-dd hh24:mi:ss') ]]>
</if>

3、in字符串正则拆分
select * from( SELECT REGEXP_SUBSTR((select pro.cfg_value from BAOCORS_WEBZ.RZ_T_PROPERTIES_CONFIG pro where pro.cfg_key='BANK_CODE_DONTPRINT_CSY'), '[^,]+', 1, LEVEL) AS STR FROM DUAL CONNECT BY LEVEL <=7) where str is not null

原文地址:https://www.cnblogs.com/caichaoxiang919/p/13139484.html