Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8288931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:23:08+00:00 2026-06-08T12:23:08+00:00

I had a user request to be able to select data by employee ID

  • 0

I had a user request to be able to select data by employee ID value or Employee Name value. In the event neither is requested pull all employees.

My first impulse was to create two variables: @EmpID and @Name

then

select a,b,c,d,e
where
(
    c between date1 and date 2
    and
    d > 0
)
and
(
    a in (@EmpID)
    or
    b = @Name
)

It works great if I supply values for @Empid or @Name.

What I can’t figure out is how to get it to return everyone if @EmpID is null and @Name is null.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:23:09+00:00Added an answer on June 8, 2026 at 12:23 pm

    Add an extra OR statement to your WHERE clause:

    and
        (
            (a = @EmpID)
            or
            (b = @Name)
            or
            (@EmpID IS NULL AND @Name IS NULL)
        )
    

    If both @EmpID and @Name are NULL, then all employees will be returned. Keep in mind that the WHERE clause:

    (
        c between date1 and date 2
        and
        d > 0
    )
    

    will still be applied to any employees selected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The story: I had class User and class Organization: User. I did not use
I have implemented mail composer. But it opens mail composer whenever user had implemented
I have implemented antiforgery token on my login page. Now I had one user
I had image for Products and i want user when click on image appear
I had .sql file in D:/xxx/User.sql file, and mysql home in c drive. Now
I had a login page. once user successfuly logged in, they can view and
Was wondering if anyone had any smart approaches to creating dynamic vanity user urls
the other day I had a bug submitted for my app from a user
My project had audit module, which includes each and every action of the user
let's say user send app requests to his friends, this request will be targeting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.