Solved

need select statement

Posted on 2007-04-09
4
146 Views
Last Modified: 2010-03-19
how do I modify this sql select statement to include some if/then logic:
SELECT DISTINCT EMAIL FROM  tblBLAH WHERE division_name=@division_name and mgr_email=@mgr_email

I want to add to this that if @division_name is 'unknown' then we need the filter to be where division_name is null...
0
Comment
Question by:acdagirl
  • 2
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18876839
SELECT DISTINCT EMAIL
FROM  tblBLAH
WHERE ( division_name=@division_name OR @division_name =  'unknown'  )
AND mgr_email=@mgr_email
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18876842
sorry, a small correction:

SELECT DISTINCT EMAIL
FROM  tblBLAH
WHERE (   ( division_name=@division_name AND @division_name <> 'unknown'  )
       OR (division_name IS NULL AND @division_name = 'unknown'  )
      )
AND mgr_email=@mgr_email
0
 

Author Comment

by:acdagirl
ID: 18876846
no, that's not what I want. it's *if* the parameter @division_name comes in as 'unknown' then select division_name is null
0
 

Author Comment

by:acdagirl
ID: 18876853
ok, I'll try the second one
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question