SELECT P.sortsnum,P.product from products P left join products_categorys_links L on L.product_id=P.id where P.producttype='QA' and L.category_id= group by P.sortsnum order by P.idYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group by P.sortsnum order by P.id' at line 1