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 '%UNKNOWN_PLACEHOLDER_0UNKNOWN_PLACEHOLDER_1UNKNOWN_PLACEHOLDER_2UNKNOWN_PLACEHOLDER_3UNKNOWN_PLACEHOLDER_4+UNKNOWN_PLACEHOLDER_5+60300%' OR LOWER(product_code) LIKE '%UNKNOWN_PLACEHOLDER_6UNKNOWN_PLACEHOLDER_7UNKNOWN_PLACEHOLDER_8UNKNOWN_PLACEHOLDER_9UNKNOWN_PLACEHOLDER_10+UNKNOWN_PLACEHOLDER_11+60300%' OR LOWER(mas_id) LIKE '%UNKNOWN_PLACEHOLDER_12UNKNOWN_PLACEHOLDER_13UNKNOWN_PLACEHOLDER_14UNKNOWN_PLACEHOLDER_15UNKNOWN_PLACEHOLDER_16+UNKNOWN_PLACEHOLDER_17+60300%' OR LOWER(masname) LIKE '%UNKNOWN_PLACEHOLDER_18UNKNOWN_PLACEHOLDER_19UNKNOWN_PLACEHOLDER_20UNKNOWN_PLACEHOLDER_21UNKNOWN_PLACEHOLDER_22+UNKNOWN_PLACEHOLDER_23+60300%' OR LOWER(nametype) LIKE '%UNKNOWN_PLACEHOLDER_24UNKNOWN_PLACEHOLDER_25UNKNOWN_PLACEHOLDER_26UNKNOWN_PLACEHOLDER_27UNKNOWN_PLACEHOLDER_28+UNKNOWN_PLACEHOLDER_29+60300%' OR LOWER(comp) LIKE '%UNKNOWN_PLACEHOLDER_30UNKNOWN_PLACEHOLDER_31UNKNOWN_PLACEHOLDER_32UNKNOWN_PLACEHOLDER_33UNKNOWN_PLACEHOLDER_34+UNKNOWN_PLACEHOLDER_35+60300%' OR LOWER(productID) LIKE '%UNKNOWN_PLACEHOLDER_36UNKNOWN_PLACEHOLDER_37UNKNOWN_PLACEHOLDER_38UNKNOWN_PLACEHOLDER_39UNKNOWN_PLACEHOLDER_40+UNKNOWN_PLACEHOLDER_41+60300%' )