From 1a5818652d622f61c4c4627756b7dadf3da7935b Mon Sep 17 00:00:00 2001 From: RomanSteinberg <romanofficial@yandex.ru> Date: Sat, 30 Aug 2014 12:00:53 +0400 Subject: [PATCH] ADD: get students not attending discipline by groupID and so on --- db/StoredProcedures.sql | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/db/StoredProcedures.sql b/db/StoredProcedures.sql index 6918a2973..4f5c65111 100644 --- a/db/StoredProcedures.sql +++ b/db/StoredProcedures.sql @@ -1031,7 +1031,44 @@ BEGIN END // +DROP PROCEDURE IF EXISTS getStudentsNotAttendingDiscipline// +CREATE PROCEDURE `getStudentsNotAttendingDiscipline` ( IN `Grade` INT, + IN `StudyGroupID` INT, + IN `FacultyID` INT, + IN `Last` VARCHAR(30) CHARSET utf8, + IN `First` VARCHAR(30) CHARSET utf8, + IN `Second` VARCHAR(30) CHARSET utf8, + IN `DisciplineID` INT + ) + NO SQL +BEGIN + SELECT students.ID AS 'StudentID', + students.LastName AS 'StudentLast', + students.FirstName AS 'StudentFirst', + students.SecondName AS 'StudentSecond', + study_groups.Grade AS 'GroupGrade', + study_groups.GroupNum AS 'GroupNum' + FROM `students` + INNER JOIN `study_groups` ON students.StudyGroupID = study_groups.ID + INNER JOIN `specializations` ON study_groups.SpecializationID = specializations.ID + LEFT JOIN `disciplines_students` ON students.ID = disciplines_students.StudentID AND + DisciplineID = disciplines_students.DisciplineID + LEFT JOIN `disciplines_groups` ON disciplines_groups.StudyGroupID = study_groups.ID AND + DisciplineID = disciplines_groups.DisciplineID + WHERE ( Grade = 0 OR study_groups.Grade = Grade) AND + ( StudyGroupID = 0 OR study_groups.ID = StudyGroupID) AND + ( FacultyID = 0 OR specializations.FacultyID = FacultyID) AND + ( students.LastName LIKE CONCAT(Last,"%") ) AND + ( students.FirstName LIKE CONCAT(First,"%") ) AND + ( students.SecondName LIKE CONCAT(Second,"%") ) AND + ( ( disciplines_students.Type IS NOT NULL AND disciplines_students.Type = 'detach' ) OR + ( disciplines_groups.ID IS NULL AND disciplines_students.Type IS NULL ) + ) + ORDER BY study_groups.Grade ASC, study_groups.GroupNum ASC; + + +END // -- GitLab