Can anyone tell me why this statement is not limiting the results to today and the last 7 days? it is showing me results from 3 months ago along with results from today. In a different post I was told I had to change from a WHERE clause to a HAVING clause. Is it related to the variable in the %trans%?
SELECT a.`post_id`, b.`name`,
MAX(case when meta_key = 'value' THEN `meta_value` ELSE NULL END) as 'Email',
MAX(CASE WHEN `meta_key` = 'value' THEN `meta_value` ELSE NULL END) as
FROM table_1 a
INNER JOIN table_2 b ON FIND_IN_SET(a.post_id, b.payment_ids)
GROUP BY a.post_id
HAVING DeliveryDate = (DATE_SUB(CURDATE(), INTERVAL 7 DAY)) AND DeliveryType = 'pickup' AND OrderStatus = 'ready' OR OrderStatus = 'transit'
ORDER BY 'DeliveryTime' DESC