Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to select a result according to the search number parameter,for example, if I pass 7, I want the sql statement like select * from student where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(CREATETIME),Now in Mybatis,I try to write like this,and also change ${pd.intervalDay} to #{pd.intervalDay},but it is wrong.How to change it?

<!-- pd is hasmap type -->
<select id="selectstudentresult" parameterType="page" resultType="pd">
select * from student
<where>
<if test="pd.intervalDay!=null">
and DATE_SUB(CURDATE(), INTERVAL ${pd.intervalDay} DAY) <= date(a.UPDATETIME)

Posted
Comments
Mohibur Rashid 16-Sep-15 20:03pm    
What library are you using for java?

1 solution

Try to use DATEDIFF instead:
DATEDIFF(CURDATE(), CREATETIME) <= 7
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900