Welcome! Log In Create A New Profile

Advanced

Multi-registered student Deletion????

Posted by DesmondMpofu 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Multi-registered student Deletion????
October 13, 2011 10:01AM
I need help with the following: In case I have a Student "John" who is registered to to two courses "CourseA" and "CourseB". So now when I need to delete "CourseB" for instance, all the students doing Course B will be deleted. But John must not be deleted because John is also registered for CourseA.

Now my question is how do we query that in the database i.e check out if a student is registered in any other course other than the one I am just about to delete???? Is there a killer MySQL statement to solve this etc???
Re: Multi-registered student Deletion????
October 13, 2011 11:29AM
Hey,

Good question, did not think about that.
I think when I delete a course I'm not going to delete the student.
What if the student wants to study another course later?
Maybe add a flag to the table that reminds the administrator that the student is not registered for anything?

72565330
avatar Re: Multi-registered student Deletion????
October 13, 2011 11:32AM
Hi Desmond,

You will need to delete the student where sno is equal to the student number being delete and also where the cid is equal to the course ID being deleted.

SQL Query:

Language: SQL
DELETE FROM `course_student` WHERE `sno` = ';1'; AND `cid` = ';1';


You substitute the 1 for the actual student number and the course ID smiling smiley

student no: 77315138
avatar Re: Multi-registered student Deletion????
October 13, 2011 11:40AM
Hi Chantal,

Remember that the student number might not be unique in the course_student table but the CID is for each student.

The student can register for lots of different courses.

You just need to query the database correctly.

student no: 77315138
Re: Multi-registered student Deletion????
October 13, 2011 11:49AM
Quote
Riaz
Hi Desmond,

You will need to delete the student where sno is equal to the student number being delete and also where the cid is equal to the course ID being deleted.

SQL Query:

I think this works ok if a student is resistered for one course. I he is registered for many other courses I don't think it works...
avatar Re: Multi-registered student Deletion????
October 13, 2011 01:11PM
DesmondMpofu Wrote:
-------------------------------------------------------
>
Quote
Riaz
> Hi Desmond,
>
> You will need to delete the student where sno is
> equal to the student number being delete and also
> where the cid is equal to the course ID being
> deleted.
>
> SQL Query:
>
>
>
> I think this works ok if a student is resistered
> for one course. I he is registered for many other
> courses I don't think it works...

I tested the query with a student registered for more than 1 course, have you tried it ?

student no: 77315138
Re: Multi-registered student Deletion????
October 13, 2011 02:14PM
Ok will try that and update everyone
Re: Multi-registered student Deletion????
October 13, 2011 03:54PM
...but it must delete from "student" table as well...if the student is registered for that one course.....
avatar Re: Multi-registered student Deletion????
October 13, 2011 08:55PM
When you delete a course it should never delete the student from the student table it should only delete the student from the course_student table.

The student table has all the student details, each student has a unique student number(sno)... The student number(sno) is how you reference students in other tables.

student no: 77315138
Sorry, only registered users may post in this forum.

Click here to login