sql - Many to Many relation query with dynamic where clause -
my tables :
table emp:- empid, empname table empdepttrans:- empdeptid, empid, deptid table dept:- deptid, deptname
business logic 1 employee can work in multiple department , 1 department can have multiple employees, many many relation.
i need in forming sql query can put conditions like:
(dept='engineering' , dept='account' ) , (dept ='library' or dept ='hr')
my condition dynamic , can change based on requirement...
as can understand question. have written condition in xml data. expression
(dept='engineering' , dept='account' ) , (dept ='library' or dept ='hr')
so need is.
create plan query show employee , department relation. add complex filter condition desire. below
declare @complex nvarchar(1000); set @complex = "(dept='engineering' , dept='account' ) , (dept ='library' or dept ='hr')" execsql query+' '+ @complex;
Comments
Post a Comment