Myself trying to pass string variable to where condition in MySQL query as given in this stack overflow answer as given below.
select @start := ' and Id=21';
select * from myTable where 1=1 @start;
SET @start = ' Id=21 ';
select * from myTable where (select @start);
No you cannot do that. The columns and the condition in the select clause needs to be fixed when you are preparing the
So you cannot make a dynamic where clause statement like the one you posted. In that example, the values in the column are dynamic not the column names.
The manual says:
A conditional object consists of one or more conditional fragments that will all be joined by a specified conjunction. By default, that conjunction is AND.