ibatis mysql數據庫 模糊查詢 時間大小比較


<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="operationType" column="operation_type" />
<result property="operationContent" column="operation_content" />
<result property="operationDate" column="operation_date" />
</resultMap>

 <!--   getLogForPage查詢where條件   -->
    <sql id="queryLogWhere"> 
<dynamic prepend="where"> 
<isNotEmpty prepend="and" property="id">
t.id=#id#
</isNotEmpty>
<isNotEmpty prepend="and" property="userId">
t.user_id  like concat('%',#userId#,'%')
</isNotEmpty>

<isNotEmpty prepend="and" property="operationType">
t.operation_type like concat('%',#operationType#,'%')
</isNotEmpty>

<isNotEmpty prepend="and" property="operationContent">
t.operation_content=#operationContent#
</isNotEmpty>
<isNotEmpty prepend="and" property="logDateStart">
<![CDATA[t.operation_date>=#logDateStart#]]> 
</isNotEmpty>
<isNotEmpty prepend="and" property="logDateEnd">
<![CDATA[t.operation_date<=#logDateEnd#]]> 
</isNotEmpty>

</dynamic>
order by t.operation_date desc
   </sql>
<!-- getLogForPage查詢入口  -->
<select id="queryLog" parameterClass="java.util.HashMap"  resultMap="logResult">
select id, user_id, operation_type, operation_content, operation_date  from t_m_log  t
<include refid="queryLogWhere" />
<dynamic prepend="">
<isNotNull property="limitStart">
<isNotNull property="limitSize">
limit #limitStart#, #limitSize# 
                 </isNotNull>
</isNotNull>
</dynamic>


</select>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章