In my query I want to add the and clause in query if a specific condition occur. See the where clause of my query
1 and ps.dept=dept.deptid
2 and ps.sdept=deptsub.deptid
3 and
4 if(ps.dept<>ps.sdept)
5 begin
6 deptsub.Parent=dept.deptid
7 end
8 and ps.deptcategory=deptcat.category
At 4 I want if condition fulfil then 6 should be added in query else not how is this possible.thanks!
How about:
and ps.dept=dept.deptid
and ps.sdept=deptsub.deptid
and ( ps.dept=ps.sdept or deptsub.Parent=dept.deptid )
and ps.deptcategory=deptcat.category
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With