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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -