Assign a string to a defined variable isWeekdays,
set @isWeekdays='calendar.monday=1 AND calendar.tuesday=1 AND calendar.wednesday=1 AND calendar.thursday=1 AND calendar.friday=1';
I expect that the variable isWeekdays can be replaced with the string while executing a query, for instance,
SELECT * FROM calendar WHERE @isWeekdays;
-- expect to
SELECT * FROM calendar WHERE calendar.monday=1 AND calendar.tuesday=1 AND calendar.wednesday=1 AND calendar.thursday=1 AND calendar.friday=1;
However, it does not take effect.
select ... where 'solidstring'. if you want the variable's contents to be evaluated/executed as part of the query, you have to use dynamic sql: build a new query string, add the variable's contents, execute the new string.@isWeekdaysmany times in my sql queries. Now, I knowdynamic queriescan make it.