根据日期获取某一时间段内的数据mysql语句


2019-08-19

根据日期时间查询某一时间段的数据可以按照以下操作,仅仅是一个sql语句的问题:

1、mapper.xml层代码

 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>    

2、mapper.java层代码

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM