2

I have a simple enough query that works well:

SELECT 
     Name, JobStatus 
FROM 
     ScheduleRequest
WHERE
     ScheduleDate >= '2018-07-11' 
AND 
     JobStatus <> 6 

I need to check for different values in the same field 'JobStatus'. When I try to alter the query like this, I'm finding only the last value of 95 is showing?

SELECT 
     Name, JobStatus
FROM 
    ScheduleRequest
WHERE
    ScheduleDate >= '2018-07-11' 
    AND (JobStatus <> 6 
        OR JobStatus <> 0 
        OR JobStatus <> 1
        OR JobStatus <> 4
        OR JobStatus <> 95
    )
1
  • 1
    Notice how everything will match as no record can have all of the values assigned to a single filed. What you wanted probably is to either use AND instead of OR or just use the proposed answer with NOT IN. Commented Jul 11, 2018 at 20:03

1 Answer 1

3

Use NOT IN expression

SELECT 
     Name, JobStatus
FROM 
    ScheduleRequest
WHERE
     ScheduleDate >= '2018-07-11' 

    AND JobStatus NOT IN (6, 0, 1, 4, 95)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.