select categories_products_rel.*, count(categories_products_rel.product_id) as nr, categories.name, categories.type from categories_products_rel join categories on categories.id=categories_products_rel.category_id and categories.type='1' where categories_products_rel.product_id in () and categories_products_rel.category_id!='298' group by categories_products_rel.category_id order by nr desc
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 ') and categories_products_rel.category_id!='298' group by cat' at line 10