SELECT DISTINCT(p.prod_id) FROM products p LEFT JOIN user u ON u.user_id = p.prod_user_id LEFT JOIN billing b ON u.user_id = b.billing_user_id WHERE b.billing_active = 1 AND u.user_active = 1 AND p.prod_active = 1 AND billing_expires > NOW()