I have three tables namely student, result and subject but whenever i try to join them i get this error message in the browser
Database query failed: Unknown column 'student.student_code' in 'field list'
here is my query
$query = "SELECT student.student_code,
student.firstname,
student.middlename,
student.lastname,
student.gender,
result.student_code,
result.subject_code,
result.mark,
subject.subject_code,
subject.subject_name ";
$query .= " FROM student AS s ";
$query .= " INNER JOIN result AS r ON s.student_code=r.student_code";
$query .= " INNER JOIN subject AS m ON m.subject_code=r.subject_code";
$query .= " WHERE student_code = '{$session_id}' ";
$query .= " LIMIT 1";
And here are the table structure
This is student table
student_code int(255) primary key
firstname varchar(250)
middlename varchar(250)
lastname varchar(250)
gender varchar(250)
school_code varchar(250)
This is result table
student_code int(255)
subject_code int(10)
mark int(10)
This is subject table
subject_code int(10)
subject_name varchar(250)