Getting character from workbook and passing it in a like condition in sql query

Hey, i need to check if a pattern exsists in my database table column. The patterns to be searched are stored in a workbook(since i dont have excel in my machine, cannot use excel scope).
So i’m getting the first pattern to a variable “patternName” through readcell. And passing it in the query like

“select count(”+columnName+“) from “+tableName+” where “+columnName+” like ’ “+patternName+” ';”

Say; i’m taking the column name and table name from different workbook ass well.

But on execution i’m getting a result of 0 on every column (which is not supposed to be the answer). But when i directly pass the pattern instead of using the variable, i’m getting the right answer.