SELECT T.*, R.venue as venueid, R.dateonrequest, R.customprice, R.discount_price, R.pricetype FROM recurring_training_date R INNER JOIN training_course T ON R.tcid = T.id LEFT JOIN training_course_accereditation_maps TCAM ON T.id=TCAM.tcid WHERE T.status='2' AND (R.dateonrequest>='2014-09-23' OR R.dateonrequest='0000-00-00') AND T.mid= GROUP BY R.tcid ORDER BY R.for_date_order, R.dateonrequest ASC 1064 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 'GROUP BY R.tcid ORDER BY R.for_date_order, R.dateonrequest ASC' at line 1