how to write a query with multiple random filters ?
-
Hi, I have to write a query where there will be multiple filters selected by user. These filters will be selected randomly in any combination (for example filters like: Co.name, deptId, Startdate, endDate, employee name, Assignment, Shifts, class) Can anyone tell me how to write such type of query? As there cn be n numbers of permutation & combination of all filters.
-
Hi, I have to write a query where there will be multiple filters selected by user. These filters will be selected randomly in any combination (for example filters like: Co.name, deptId, Startdate, endDate, employee name, Assignment, Shifts, class) Can anyone tell me how to write such type of query? As there cn be n numbers of permutation & combination of all filters.
one solution that I have used before is
select *
from table
where ((@endDate is null) or (enddate = @enddate)) and
((@deptid is null) or (deptid = @deptid)) and
((@employeeName is null) or (employeeName = @employeeName))Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON
-
one solution that I have used before is
select *
from table
where ((@endDate is null) or (enddate = @enddate)) and
((@deptid is null) or (deptid = @deptid)) and
((@employeeName is null) or (employeeName = @employeeName))Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON
Thanks Simon..for ur reply will implement this today and let u know..hope this works for me.
-
one solution that I have used before is
select *
from table
where ((@endDate is null) or (enddate = @enddate)) and
((@deptid is null) or (deptid = @deptid)) and
((@employeeName is null) or (employeeName = @employeeName))Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON
This is not working in case I dont give deptid or any one of parameters. pls help me.
-
This is not working in case I dont give deptid or any one of parameters. pls help me.
What simon supplied is the idea/concept of how it should be done, writing the actual query is up to you. The sample shows you that simon is testing the value of the variable to find out if it is null and if it is not null then applying the filter. You need to understand the concept and extend it to your needs. That is called learning!
Never underestimate the power of human stupidity RAH
-
This is not working in case I dont give deptid or any one of parameters. pls help me.
Share your query first
thatraja
Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute