如何从sql表中检索数据并将其插入另一个表中

I am developing a 'online students discussion platform' for a certain university, i want a student to post a question to only students belonging in the same faculty so that if ICT student posts a question, the system extracts all the students in ICT faculty from the students table, attaches them to the post and inserts them into the table receivers.

The system is extracting all students from the students table but it is inserting only one student in the table receivers.

TABLES:

-students(regno,name,faculty_code) PRIMARY KEY regn
-receivers(id, regno,message_id)

how to do it?

Instead of having a table for receivers, a better approach would be for you to have a "faculty_code" field in the "message" table which would be populated with the faculty_code of the poster. So for each student, extract messages where student.faculty_code is equal to message.faculty_code.

That way a student only sees messages posted by students in the same faculty as him/her.