You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE 1 AND .`` LIKE '%%' ORDER BY TRIM(BOTH ' ' FROM ``.``)' at line 1: SELECT DISTINCT ``.`` AS COL_NAME FROM WHERE 1 AND .`` LIKE '%%' ORDER BY TRIM(BOTH ' ' FROM ``.``)