RSS Forums RSS
Please support our MS SQL advertiser: Programming Forums

In-line If-Else Block?

Join Date: Apr 2006
Posts: 2
Reputation: versatilewt is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
versatilewt versatilewt is offline Offline
Newbie Poster

Re: In-line If-Else Block?

  #3  
Apr 20th, 2006
Thanks for the reply. I don't have access to create procedures on the system, though I probably should. I think I over simplified my question a bit. Here's exactly what I'm trying to do. I want to set WHERE conditions optionally, based on a subquery.

The data isn't given explicity, so I have to kind of infer it through the query. I want to set a where condition of e.stafflevelid = m.stafflevelid and project_dept = manager_dept ONLY when then Manager level is, say 4 (which is determined from a subquery).

So, for the query
[php]

WHERE
e.active <> 0
AND
/* THIS IS THE OPTIONAL WHERE CONDITION */
/* IF THE MANAGER'S STAFF LEVEL SATISFIES SUBQUERY*/
(mgr.stafflevelid IN (/* HERE WOULD BE SUBQUERY*/)
/* THEN SET THESE WHERE CONDITIONS*/
e.stafflevelid=m.stafflevelid
p.dept = m.dept)
[/php]

And, I want this condition to run with other WHERE statements

I know it's not pretty, but I'm working with bad structure. Hopefully this isn't too confusing.

Thanks,

Brian
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:21 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC