php - mysql syntax error in a join query -
php - mysql syntax error in a join query -
i facing mysql syntax error next query.
select student_info.grade, student_info.section, student_info.student_name, mwf.* student_info inner bring together mwf on student_info.student_gen_id = mwf.mwf_student_id mwf.mwf_month =".$current_month error
you have error in sql syntax; check manual corresponds mysql server version right syntax utilize near ' 2014' @ line 4
here mwf_month string type value passing current_month october, 2014
what doing wrong? in advance.
update
complete model function generating query
public function transaction_report_total($current_month) { $sql = "select student_info.grade, student_info.section, student_info.student_name, mwf.* student_info inner bring together mwf on student_info.student_gen_id = mwf.mwf_student_id mwf.mwf_month = '" . $current_month."'"; $query = $this->db->query($sql); homecoming $query->result_array(); }
since type of mwf_month string, need add together single quotes between $current_month below
select student_info.grade, student_info.section, student_info.student_name, mwf.* student_info inner bring together mwf on student_info.student_gen_id = mwf.mwf_student_id mwf.mwf_month = '".$current_month."' update
it looks sql statement ends after $current_month, double quote in end needed
$sql = "select student_info.grade, student_info.section, student_info.student_name, mwf.* student_info inner bring together mwf on student_info.student_gen_id = mwf.mwf_student_id mwf.mwf_month = '".$current_month."'"; php mysql
Comments
Post a Comment