Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2012

    Unanswered: Using And/Or - Not Sure Which Is Correct

    This is my syntax - I want it to return records where both of this conditions are true ... Condition 1 - employeeStatus is not in ('','','','','','','') Condition 2 - employeeStatus Not Like ('%pending%')....
    I think the syntax should read like so - but I am getting different results returned than what I feel is accurate so thought I would ask for assistance starting with the Where clause
    Select EmployeeName, SupervisorName, employeeTotalSales, yrsOfService
    From salesDB
    Where employeeStatus Not In ('Terminated', 'No Longer With Company', 'Retired', 'Left Company', 'On Leave', 'Suspended')
    OR employeeStatus Not Like ('%pending%')

  2. #2
    Join Date
    Apr 2012
    I believe you should use And, because all the status of the first condition will return true for the second condition, causing the row to be returned.

  3. #3
    Join Date
    Feb 2008
    both of this conditions are true
    Then, the where condition should be
    WHERE (Condition 1) AND (Condition 2)
    , even if Condition 1 and/or Condition 2 include NOT.

    Another thought...
    your both conditions include NOT,
    then another possible where condition might be
    WHERE NOT ( employeeStatus in ('','','','','','','') OR employeeStatus Like '%pending%' )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts