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+e+200/UNKNOWN_PLACEHOLDER_option=com_ckforms%' OR LOWER(product_code) LIKE '%samsung+e+200/UNKNOWN_PLACEHOLDER_option=com_ckforms%' OR LOWER(mas_id) LIKE '%samsung+e+200/UNKNOWN_PLACEHOLDER_option=com_ckforms%' OR LOWER(masname) LIKE '%samsung+e+200/UNKNOWN_PLACEHOLDER_option=com_ckforms%' OR LOWER(nametype) LIKE '%samsung+e+200/UNKNOWN_PLACEHOLDER_option=com_ckforms%' OR LOWER(comp) LIKE '%samsung+e+200/UNKNOWN_PLACEHOLDER_option=com_ckforms%' OR LOWER(meta_keywords) LIKE '%samsung+e+200/UNKNOWN_PLACEHOLDER_option=com_ckforms%' OR LOWER(productID) LIKE '%samsung+e+200/UNKNOWN_PLACEHOLDER_option=com_ckforms%' )