1055. Query Error 1055: Expression #2 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'admin_shopru.cp1.sort' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by Query: SELECT p.*,p.id,(p.count > 0 || p.count IS NULL) AS in_stock FROM shop_product p JOIN shop_category_products cp1 ON p.id = cp1.product_id WHERE p.status = 1 AND cp1.category_id IN(61,75,96,100,109,116,125,150) GROUP BY p.id ORDER BY in_stock DESC,cp1.sort ASC, p.id LIMIT 30