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);