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 '%samsung%' OR LOWER(product_code) LIKE '%samsung%' OR LOWER(mas_id) LIKE '%samsung%' OR LOWER(nametype) LIKE '%samsung%' OR LOWER(comp) LIKE '%samsung%' OR LOWER(contry) LIKE '%samsung%' OR LOWER(productID) LIKE '%samsung%' ) AND ( LOWER(name) LIKE '% UNKNOWN_PLACEHOLDER_0') AND ( LOWER(name) LIKE '%350%' OR LOWER(product_code) LIKE '%350%' OR LOWER(mas_id) LIKE '%350%' OR LOWER(nametype) LIKE '%350%' OR LOWER(comp) LIKE '%350%' OR LOWER(contry) LIKE '%350%' OR LOWER(productID) LIKE '%350%' ) AND ( LOWER(name) LIKE '%and%' OR LOWER(product_code) LIKE '%and%' OR LOWER(mas_id) LIKE '%and%' OR LOWER(nametype) LIKE '%and%' OR LOWER(comp) LIKE '%and%' OR LOWER(contry) LIKE '%and%' OR LOWER(productID) LIKE '%and%' ) AND ( LOWER(name) LIKE '%if(1=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\''0=a%' OR LOWER(product_code) LIKE '%if(1=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\''0=a%' OR LOWER(mas_id) LIKE '%if(1=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\''0=a%' OR LOWER(nametype) LIKE '%if(1=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\''0=a%' OR LOWER(comp) LIKE '%if(1=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\''0=a%' OR LOWER(contry) LIKE '%if(1=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\''0=a%' OR LOWER(productID) LIKE '%if(1=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\''0=a%' )