I am (ahmkml36@gmail.com) looking to hire 6 great PHP programmers (full time works from home) so I interviewed smart female developer and I asked her to solve this task and this was her reply:
Solution One:
FROM users WHERE u.id NOT IN (SELECT i.user_id FROM invoices i WHERE i.invoice_date=CURRENT_DATE()) // This line was added to solve the issue. AND u.expires_on between DATE_ADD(DATE_SUB(current_date(), INTERVAL 7 DAY), INTERVAL 1 MONTH) and DATE_ADD(current_date(), INTERVAL 1 MONTH) AND u.activated=1 AND u.subscription='yearly' group by u.id
Solution Two: I found another solution to this problem. I found many ways of managing cronJobs and when jobs are misfired then there should be a recovery process, so it is possible to have Cron to solve the problem by itself.
cheers