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 ')) order by tbl_povv1.sort_order asc' at line 1 SQL query : select distinct tbl_povv1.variantID, tbl_povv1.option_value from SS_product_options_set tbl_pos1, SS_products_opt_val_variants tbl_povv1, SS_products prd_tbl1, SS_categories c_tbl1 where (prd_tbl1.categoryID=c_tbl1.categoryID) and (c_tbl1.c_enabled=1) and (prd_tbl1.productID=tbl_pos1.productID) and tbl_pos1.optionID='7' and tbl_pos1.variantID=tbl_povv1.variantID and tbl_povv1.optionID='7' and tbl_povv1.not_show_in_filter='0' and (not prd_tbl1.categoryID in (239,240,259,260,261,262,263,283,308,309,301,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464)) and (not prd_tbl1.categoryID in ()) order by tbl_povv1.sort_order asc