When I execute the query below, it returns NULL.
SELECT SUM(t.coupon_quantity)
FROM transaction t, coupon c, supplier s
WHERE MONTH(date_entered) = MONTH(CURDATE())
AND YEAR(date_entered) = YEAR(CURDATE())
AND t.coupon_id = c.id
AND c.supplier_id = s.id
AND s.id IN (SELECT us.supplier_id FROM user_supplier us WHERE us.user_id = 4);
When I take out the last line, it returns records, but when I add it, I get nothing so it leads me to believe that it's an issue with my subquery.
When I execute the subquery on it's own, I get two IDs, (14 and 15). And when I replace the subquery with: "AND s.id IN (14,15);" ...it works. Any thoughts?