Si У меня есть хранимая процедура MySql, которую я использую для фильтра gridview.Для 3 столбцов я должен написать это много комбинаций запросов.Я должен использовать фильтры на 7 столбцов, и это составит 7x7x7x7x7x7x7 числовых комбинаций.Есть ли лучший способ сделать это?
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetApprovedData`
(in siteValue varchar(45),
in skillValue varchar(100), in shiftValue varchar(100))
BEGIN
IF siteValue IS NULL and skillValue IS NULL and shiftValue IS NULL THEN
select * from approved;
ELSEIF siteValue IS NULL and skillValue IS NULL and shiftValue IS NOT NULL THEN
select * from approved where shift = shiftValue;
ELSEIF siteValue IS NULL and skillValue IS NOT NULL and shiftValue IS NULL THEN
select * from approved where skill = skillValue;
ELSEIF siteValue IS NOT NULL and skillValue IS NULL and shiftValue IS NULL THEN
select * from approved where site = siteValue;
ELSEIF siteValue IS NULL and skillValue IS NOT NULL and shiftValue IS NOT NULL THEN
select * from approved where skill = skillValue and shift = shiftValue;
ELSEIF siteValue IS NOT NULL and skillValue IS NOT NULL and shiftValue IS NULL THEN
select * from approved where site = siteValue and skill = skillValue;
ELSEIF siteValue IS NOT NULL and skillValue IS NULL and shiftValue IS NOT NULL THEN
select * from approved where site = siteValue and shift = shiftValue;
ELSE
select * from approved where site = siteValue and skill = skillValue and shift = shiftValue;
END IF;
END