Hi,
I am trying to generate a MySQL query dynamically using a variable. The query runs fine without the variable and returns 7 results when I just type the column name (clicks.LPID) but when I use a variable with string value "clicks.LPID" it fails to GROUP BY and returns single row.
It also doesn't work when I use a variable with integer value "3". It works fine if I just type 3.
I tried switching off the prepared statements, then the query returns no results.
Example query ->
SELECT clicks.name, sales.SUM(sales), clicks.LPID, sales.click_id
FROM sales
JOIN clicks
ON sales.click_id= clicks.click_id
AND sales.campaign_id = {{ url_params.value["camp_id"] }}
WHERE CAST(sales.sale_date AS Date) BETWEEN {{daterangepicker1.startFormattedString}} AND {{daterangepicker1.endFormattedString}}
GROUP BY {{ state1.value }}
Could you please help me with this?