Search Posts

Inserting data from one table to another | mysql

I’m currently learning and I’m working on a little test project. Thing is, I have five tables:

Login, where I keep login information for students:

IDUser | Name | Surname | Username   | Password
1      | John | Smith   | john.smith | john123

Students, where I keep basic informations about students

IDStudent | Name | Surname
1         | John | Smith 

Professors, where I keep basic informations about professors

IDProfessor | Name | Surname 
1           | Mike | Petersen

Subjects, where I keep basic information about subjects

IDSubject | SubjectName | ProfessorName
1         | Programming | Gary Williams

and for a final table, in which I need to insert data from tables above, I have Courses:

IDCourse | StudentID | SubjectID | ProfessorID
1        | ??        | ???       | ????

The question is, how do I insert data in Course table from tables above. I’m currently using MySql as my database, and I’ve created foreign keys and connected them with the primary keys. I also have a ComboBox (filled with subjects from Subjects table) where a student can choose a Subject and by pressing the button, insert it in a Courses table.

Source: Stackoverflow

Leave a Reply

Your email address will not be published. Required fields are marked *