[Solved] no such table: main.course_name


Unfortunately i did not write any query to create the above table
causing the error.

Assuming that you really meant to say i did not write any query to use the above table; you did implicitly by defining teacher_table table with :-

    +"FOREIGN KEY("+courseId+")"+" REFERENCES "+CourseTable.courseName+"("+CourseTable.courseID+")"

That is to insert into the teacher_table the value in the courseId column must match the specified column (whatever CourseTable.courseID resolves to) in the course_name table (i.e. CourseTable.courseName resolves to course_name).

However, as the table course_name doesn’t exist the FOREIGN KEY constraint cannot even be checked. Hence the failure.

You MUST define the course_name table and you must also populate it with appropriate values unless you remove the FOREIGN KEY constraint.

1

solved no such table: main.course_name