2019-08-19java
根據日期時間查詢某一時間段的數據能夠按照如下操做,僅僅是一個sql語句的問題:sql
1 <select id="findTaxDetails" resultType="com.example.pojo.TaxDetails"> 2 select td_tax_date, td_tax_payable, td_detail from tax_details 3 inner join contractor 4 on contractor.ct_id = tax_details.ct_id 5 where contractor.mobile = #{mobile} 6 <if test="startDate != null and startDate != ''"> //關鍵位置 7 and td_tax_date <![CDATA[>=]]> #{startDate} 8 </if> 9 <if test="endDate != null and endDate != ''"> 10 and td_tax_date <![CDATA[<=]]> #{endDate} 11 </if> 12 </select>
1 /** 2 * 收入查看,根據公司名稱或者月份匹配 3 * @param startDate 查詢的開始時間 4 * @param endDate 查詢的結束時間
5 * @return 6 */ 7 List<IncomeDetails> findIncomeDetails(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("mobile")String mobile, @Param("customerId")Integer customerId);