I have been stuck with this issue for hours now.
I have a table called subscribe with the following fields
- id (int)
- sub_type (week, month, year) (Varchar)
- sub_duration (int)
- last_renewal (Date)
I want to merge the sub_duration and sub_type and add it to the last_renewal (to get the expiring date), Then check if the result is greater/lesser than the current date. Below is what I have done.
SELECT s.*
FROM subscription s
WHERE (SELECT DATE_ADD(s.last_renewal, INTERVAL (CONCAT(s.sub_duration), ' ', s.sub_type)))< CURDATE()