How to add Replace (mysql) function in view query condition field
I don't think condition is what you want, rather expression. And then, to use that expression as a condition, you might need to use havingCondition-- but I'm not sure, test it out. Also note that you need % for a wildcard matching in SQL, so you might have to do -&gt;havingCondition('title', '%' . $category . '%', 'LIKE');.

So, your final code might look something like this:

$query = db_select('node', 'n')
  -&gt;addExpression('REPLACE(n.title, \' \', \'\')', 'title')
  -&gt;condition('type', 'article', '=')
  -&gt;havingCondition('title', '%' . $category . '%', 'LIKE');