From 363da2864cdff8667e3c43c8427abbdf95c28c3b Mon Sep 17 00:00:00 2001
From: PavelBegunkov <asml.Silence@gmail.com>
Date: Wed, 24 Sep 2014 21:56:07 +0400
Subject: [PATCH] load stud fix

---
 db/StoredProcedures.sql |  6 ++++--
 db/fix.sql              | 10 ++--------
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/db/StoredProcedures.sql b/db/StoredProcedures.sql
index 01a9595f1..94b293787 100644
--- a/db/StoredProcedures.sql
+++ b/db/StoredProcedures.sql
@@ -1203,8 +1203,10 @@ BEGIN
 		SELECT study_groups.ID 
 		INTO SG_ID
 		FROM `study_groups`
-		WHERE 	study_groups.GroupNum = groupNum AND
-				study_groups.GradeID = gradeID
+		INNER JOIN `specializations` ON study_groups.SpecializationID = specializations.ID
+	 	WHERE 	study_groups.GroupNum = groupNum AND
+				study_groups.GradeID = gradeID AND
+				specializations.FacultyID = FacultyID 
 		LIMIT 1;
 		IF SG_ID <= 0 THEN
 			RETURN -1;
diff --git a/db/fix.sql b/db/fix.sql
index 96161a436..0bfa29401 100644
--- a/db/fix.sql
+++ b/db/fix.sql
@@ -17,7 +17,7 @@ SELECT @AccID;
 DELETE FROM `students`
 WHERE students.ID >= (SELECT @stID);
 
-ALTER TABLE students AUTO_INCREMENT = 798;
+ALTER TABLE students AUTO_INCREMENT = 797;
 
 
 DELETE FROM `accounts`
@@ -29,10 +29,4 @@ ALTER TABLE accounts AUTO_INCREMENT = 1085;
 DELETE FROM `study_groups`
 WHERE study_groups.SpecializationID = 7;
 
-ALTER TABLE study_groups AUTO_INCREMENT = 62;
-
-
-DELETE FROM `grades`
-WHERE grades.ID = 8;
-
-ALTER TABLE study_groups AUTO_INCREMENT = 8;
\ No newline at end of file
+ALTER TABLE study_groups AUTO_INCREMENT = 61;
-- 
GitLab