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 'ERROR: SELECT COUNT(DISTINCT p.productID) FROM ?#PRODUCTS_TABLE p where catego' at line 1 SQL query : ERROR: SELECT COUNT(DISTINCT p.productID) FROM ?#PRODUCTS_TABLE p where categoryID>1 and enabled=1 and ( LOWER(name) LIKE '%aenieae%' OR LOWER(product_code ) LIKE '%aenieae%' OR LOWER(brief_description) LIKE '%aenieae%' ) AND ( LOWER(name) LIKE '%aey%' OR LOWER(product_code ) LIKE '%aey%' OR LOWER(brief_description) LIKE '%aey%' ) AND ( LOWER(name) LIKE '%iUNKNOWN_PLACEHOLDER_anoeUNKNOWN_PLACEHOLDER_ei%' OR LOWER(product_code ) LIKE '%iUNKNOWN_PLACEHOLDER_anoeUNKNOWN_PLACEHOLDER_ei%' OR LOWER(brief_description) LIKE '%iUNKNOWN_PLACEHOLDER_anoeUNKNOWN_PLACEHOLDER_ei%' ) AND ( LOWER(name) LIKE '%4040%' OR LOWER(product_code ) LIKE '%4040%' OR LOWER(brief_description) LIKE '%4040%' )