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_4UNKNOWN_PLACEHOLDER_5+(UNKNOWN_PLACEHOLDER_6UNKNOWN_PLACEHOLDER_7UNKNOWN_PLACEHOLDER_8UNKNOWN_PLACEHOLDER_9UNKNOWN_PLACEHOLDER_10UNKNOWN_PLACEHOLDER_11UNKNOWN_PLACEHOLDER_12UNKNOWN_PLACEHOLDER_13UNKNOWN_PLACEHOLDER_14UNKNOWN_PLACEHOLDER_15UNKNOWN_PLACEHOLDER_16+UNKNOWN_PLACEHOLDER_17UNKNOWN_PLACEHOLDER_18+nokia+UNKNOWN_PLACEHOLDER_19+50%' OR LOWER(product_code ) LIKE '%UNKNOWN_PLACEHOLDER_20UNKNOWN_PLACEHOLDER_21UNKNOWN_PLACEHOLDER_22UNKNOWN_PLACEHOLDER_23UNKNOWN_PLACEHOLDER_24UNKNOWN_PLACEHOLDER_25+(UNKNOWN_PLACEHOLDER_26UNKNOWN_PLACEHOLDER_27UNKNOWN_PLACEHOLDER_28UNKNOWN_PLACEHOLDER_29UNKNOWN_PLACEHOLDER_30UNKNOWN_PLACEHOLDER_31UNKNOWN_PLACEHOLDER_32UNKNOWN_PLACEHOLDER_33UNKNOWN_PLACEHOLDER_34UNKNOWN_PLACEHOLDER_35UNKNOWN_PLACEHOLDER_36+UNKNOWN_PLACEHOLDER_37UNKNOWN_PLACEHOLDER_38+nokia+UNKNOWN_PLACEHOLDER_39+50%' OR LOWER(brief_description) LIKE '%UNKNOWN_PLACEHOLDER_40UNKNOWN_PLACEHOLDER_41UNKNOWN_PLACEHOLDER_42UNKNOWN_PLACEHOLDER_43UNKNOWN_PLACEHOLDER_44UNKNOWN_PLACEHOLDER_45+(UNKNOWN_PLACEHOLDER_46UNKNOWN_PLACEHOLDER_47UNKNOWN_PLACEHOLDER_48UNKNOWN_PLACEHOLDER_49UNKNOWN_PLACEHOLDER_50UNKNOWN_PLACEHOLDER_51UNKNOWN_PLACEHOLDER_52UNKNOWN_PLACEHOLDER_53UNKNOWN_PLACEHOLDER_54UNKNOWN_PLACEHOLDER_55UNKNOWN_PLACEHOLDER_56+UNKNOWN_PLACEHOLDER_57UNKNOWN_PLACEHOLDER_58+nokia+UNKNOWN_PLACEHOLDER_59+50%' )