This is something that must be handled at the datatabase level. You will need to check in database that particular subect has been assigned then it should be filtered out.
You can make use of NOT IN. For example
SELECT Subjects FROM SubjectsTable
WHERE Subject
NOT IN (SELECT Subject FROM AssignedSubjects)