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' OR LOWER(product_code) LIKE '%UNKNOWN_PLACEHOLDER_5UNKNOWN_PLACEHOLDER_6UNKNOWN_PLACEHOLDER_7UNKNOWN_PLACEHOLDER_8UNKNOWN_PLACEHOLDER_9' OR LOWER(mas_id) LIKE '%UNKNOWN_PLACEHOLDER_10UNKNOWN_PLACEHOLDER_11UNKNOWN_PLACEHOLDER_12UNKNOWN_PLACEHOLDER_13UNKNOWN_PLACEHOLDER_14' OR LOWER(masname) LIKE '%UNKNOWN_PLACEHOLDER_15UNKNOWN_PLACEHOLDER_16UNKNOWN_PLACEHOLDER_17UNKNOWN_PLACEHOLDER_18UNKNOWN_PLACEHOLDER_19' OR LOWER(nametype) LIKE '%UNKNOWN_PLACEHOLDER_20UNKNOWN_PLACEHOLDER_21UNKNOWN_PLACEHOLDER_22UNKNOWN_PLACEHOLDER_23UNKNOWN_PLACEHOLDER_24' OR LOWER(comp) LIKE '%UNKNOWN_PLACEHOLDER_25UNKNOWN_PLACEHOLDER_26UNKNOWN_PLACEHOLDER_27UNKNOWN_PLACEHOLDER_28UNKNOWN_PLACEHOLDER_29' OR LOWER(meta_keywords) LIKE '%UNKNOWN_PLACEHOLDER_30UNKNOWN_PLACEHOLDER_31UNKNOWN_PLACEHOLDER_32UNKNOWN_PLACEHOLDER_33UNKNOWN_PLACEHOLDER_34' OR LOWER(productID) LIKE '%UNKNOWN_PLACEHOLDER_35UNKNOWN_PLACEHOLDER_36UNKNOWN_PLACEHOLDER_37UNKNOWN_PLACEHOLDER_38UNKNOWN_PLACEHOLDER_39' ) AND ( LOWER(name) LIKE '%UNKNOWN_PLACEHOLDER_40UNKNOWN_PLACEHOLDER_41' OR LOWER(product_code) LIKE '%UNKNOWN_PLACEHOLDER_42UNKNOWN_PLACEHOLDER_43' OR LOWER(mas_id) LIKE '%UNKNOWN_PLACEHOLDER_44UNKNOWN_PLACEHOLDER_45' OR LOWER(masname) LIKE '%UNKNOWN_PLACEHOLDER_46UNKNOWN_PLACEHOLDER_47' OR LOWER(nametype) LIKE '%UNKNOWN_PLACEHOLDER_48UNKNOWN_PLACEHOLDER_49' OR LOWER(comp) LIKE '%UNKNOWN_PLACEHOLDER_50UNKNOWN_PLACEHOLDER_51' OR LOWER(meta_keywords) LIKE '%UNKNOWN_PLACEHOLDER_52UNKNOWN_PLACEHOLDER_53' OR LOWER(productID) LIKE '%UNKNOWN_PLACEHOLDER_54UNKNOWN_PLACEHOLDER_55' ) AND ( LOWER(name) LIKE '%samsung%' OR LOWER(product_code) LIKE '%samsung%' OR LOWER(mas_id) LIKE '%samsung%' OR LOWER(masname) LIKE '%samsung%' OR LOWER(nametype) LIKE '%samsung%' OR LOWER(comp) LIKE '%samsung%' OR LOWER(meta_keywords) LIKE '%samsung%' OR LOWER(productID) LIKE '%samsung%' ) AND ( LOWER(name) LIKE '%w%' OR LOWER(product_code) LIKE '%w%' OR LOWER(mas_id) LIKE '%w%' OR LOWER(masname) LIKE '%w%' OR LOWER(nametype) LIKE '%w%' OR LOWER(comp) LIKE '%w%' OR LOWER(meta_keywords) LIKE '%w%' OR LOWER(productID) LIKE '%w%' ) AND ( LOWER(name) LIKE '%5250%' OR LOWER(product_code) LIKE '%5250%' OR LOWER(mas_id) LIKE '%5250%' OR LOWER(masname) LIKE '%5250%' OR LOWER(nametype) LIKE '%5250%' OR LOWER(comp) LIKE '%5250%' OR LOWER(meta_keywords) LIKE '%5250%' OR LOWER(productID) LIKE '%5250%' )