I have this SQL query in my controller at laravel
$distinct_course = DB::table('student')
->select(DB::raw('count(*) as grad_count, `student_course`, MONTH(`student_date_ended`)'))
->where('student_course', '=', 'Basic Computer')
->whereYear('student_date_ended', '=', '2015')
->groupby(DB::raw('MONTH(`student_date_ended`'))
->get();
Which is based on this SQL query I made to work first before converting it to Laravel
select count(*) as grad_count, `student_course`, MONTH(`student_date_ended`) from `student` where `student_course` = "Basic Computer" and year(`student_date_ended`) = 2015 group by MONTH(`student_date_ended`)
But for some reason I always get this error.
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 (SQL: select count(*) as grad_count,
student_course, MONTH(student_date_ended) fromstudentwherestudent_course= Basic Computer and year(student_date_ended) = 2015 group by MONTH(student_date_ended)
Am I doing something wrong here that I'm not aware of?