consider a table.
id count dates
1 10 2016-11-12
2 20 2016-11-12
3 20 2016-11-12
4 20 2016-11-13
5 20 2016-11-13
6 20 2016-11-14
i am creating a test.sql file which contains
select * from table_name where dates = 2016-11-12;
if i have to find rows for date 2016-11-13 i have to change where condition in my .sql file.
what i want is can i declare a variable name at the top of my .sql or outside my file
which has variable DateSelect
and i only change that and date in my .sql changes automatically.
for eg.
inside test.sql
declare DateSelect = 2016-11-12
select * from table_name where dates = DateSelect;
and then i can change DateSelect to whatever i want.
i came across this documentation, but i couldn't understand it fully as i am new to mysql.Variable substitution in SQL statements Any ideas how do i achieve that, thanks in advance