From 8b799e414455984956c4fe1b8f2b8d2cf13cb5e7 Mon Sep 17 00:00:00 2001
From: PavelBegunkov <asml.Silence@gmail.com>
Date: Fri, 29 Aug 2014 20:26:38 +0400
Subject: [PATCH] condition improvment

---
 db/StoredProcedures.sql | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/db/StoredProcedures.sql b/db/StoredProcedures.sql
index 9a4599fdf..dc0348243 100644
--- a/db/StoredProcedures.sql
+++ b/db/StoredProcedures.sql
@@ -1022,12 +1022,8 @@ BEGIN
 			( students.LastName LIKE CONCAT(Last,"%") ) AND 
 			( students.FirstName LIKE CONCAT(First,"%") ) AND
 			( students.SecondName LIKE CONCAT(Second,"%") ) AND
-			( 	disciplines_students.Type = 'detach' OR 
-				( 	disciplines_groups.ID IS NULL AND  
-					( 	disciplines_students.Type IS NULL OR
-						disciplines_students.Type != 'attach'
-					)
-				)
+			( 	( 	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;
-- 
GitLab