I'm using the following query for a dynamic range in the where clause, and it seems to be converting it appropriately but still giving me syntax error. Can someone help with this?
SELECT
actions.user_id,
u.website,
YEAR(u.signup_date) AS signup_year,
u.sector,
u.account_status,
COUNT(actions.id) AS total_actions
FROM actions
JOIN users u
ON u.id = actions.user_id
AND u.plan_id NOT IN (100, 200) -- Excluding certain plan types
WHERE DATE(actions.action_date) BETWEEN {{date_range}} -- this resolves rightly, yet syntax err
GROUP BY actions.user_id
ORDER BY u.account_status;
The error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BETWEEN '2023-01-01' AND '2023-12-31' GROUP BY audits.company_id ORDER B' at line 13