diff --git a/db/StoredProcedures.sql b/db/StoredProcedures.sql
index 51e6079419b6c7c753f5c0c1ad3135620f866a5b..4802fd275b5c37bebc6b8bd03846b044d30f1e58 100644
--- a/db/StoredProcedures.sql
+++ b/db/StoredProcedures.sql
@@ -1183,7 +1183,8 @@ BEGIN
 			WHERE 	disciplines.SubjectID = SubjectID 	AND
 					disciplines.SemesterID = semID 		AND
 					(	disciplines_students.Type = 'attach'	OR
-						(disciplines_students.Type != 'detach' AND disciplines_groups.StudyGroupID = groupID )
+						((disciplines_students.Type IS NULL OR disciplines_students.Type != 'detach') AND 
+						disciplines_groups.StudyGroupID = groupID )
 					)
 			LIMIT 1;