The problem lies in your SQL statement,
If you try to execute the statement, the first ‘?’ will be not be treated as column name . Instead it wil be treated as ‘string’. So no matter whatever you pass, it will never return you a correct result. For example you give “mytable.col2” and “456” as the value. In your view- the sQL should be
“select myTable1, myTable2 where mytable1.col2=456 and myTable1.ID =myTable2.ID”.
But thast not true, your SQL is forming as
select myTable1, myTable2 where ‘mytable1.col2’=‘456’ and myTable1.ID =myTable2.ID
Which will never be true.
I think you wanted to pass the column name as a query parameter.