J
Joe Clark
This is kind of a SQL question. I have a teaching database of
students and classes, and I've made a feature that lets the teacher
(me) look at the whole database and select the students to add to his
class. The reason is that I often get my class roster as an Excel
file and it's easier to Import them all to the table, then attach them
to the class. This is a many-to-many link with a Class_Student table
whose dual primary key is "classID" and "studentID".
I've got a pop-up form that shows the roster, I've added a "selected"
checkbox field to each Student record, and have worked up "check all",
"uncheck selection" and so on. Now I want to create the "Add to the
class" button and I'm not sure how to do it.
One way I suppose is to loop through the list of students and, if the
student is "checked", run a SELECT query to find out if there's
already a linking record in Class_Student, then run an INSERT query to
Class_Student. That seems like a lot of SQL queries.
An alternative way might be to simply not -show- the students that are
already -in- the class, then I wouldn't have to check each one for a
linking record. But how do I create such a query? It has to list all
the Students NOT linked to the Class, even those linked to some other
class, and only show each one once. My SQL skill is not up to it.
students and classes, and I've made a feature that lets the teacher
(me) look at the whole database and select the students to add to his
class. The reason is that I often get my class roster as an Excel
file and it's easier to Import them all to the table, then attach them
to the class. This is a many-to-many link with a Class_Student table
whose dual primary key is "classID" and "studentID".
I've got a pop-up form that shows the roster, I've added a "selected"
checkbox field to each Student record, and have worked up "check all",
"uncheck selection" and so on. Now I want to create the "Add to the
class" button and I'm not sure how to do it.
One way I suppose is to loop through the list of students and, if the
student is "checked", run a SELECT query to find out if there's
already a linking record in Class_Student, then run an INSERT query to
Class_Student. That seems like a lot of SQL queries.
An alternative way might be to simply not -show- the students that are
already -in- the class, then I wouldn't have to check each one for a
linking record. But how do I create such a query? It has to list all
the Students NOT linked to the Class, even those linked to some other
class, and only show each one once. My SQL skill is not up to it.