2011-11-14 52 views
0

想要獲取訂閱將在MySQL中過期5天的記錄。想要獲取訂閱將在5天內在mysql中過期的記錄

使用查詢 -

select * 
from tbl_users user 
inner join tbl_purchase_plan plan on (user.cc_plan_option_id=plan.id) 
where DATE_SUB(user.created, INTERVAL plan.plan_duration MONTH) = (CURDATE() + INTERVAL 3 DAY) 
    and user.status=1 

回答

0
select * 
from tbl_users user 
inner join tbl_purchase_plan plan on (user.cc_plan_option_id=plan.id) 
where DATEDIFF(CURDATE(),DATE_ADD(user.created, INTERVAL plan.plan_duration MONTH)) = 5 
and user.status=1