Skip to Content

SQL <> function help

I'm trying to get <> function work, and it seems like I'm doing something wrong. I'm trying to not include values 411000 and 411005 by including them in a bracket with <> function. I'm told that the requirement is to use "OR" here. When I run the below code, the result includes both values. What am I doing wrong?

select u.IncidentNumber, u.PrimaryRoleOfUnit
from INC_UnitInformation u
where (u.PrimaryRoleOfUnit  <> 411000 or u.PrimaryRoleOfUnit <> 411005)
SQL
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Feb 13 at 11:14 PM
    select u.IncidentNumber, u.PrimaryRoleOfUnit
    from INC_UnitInformation u
    where (u.PrimaryRoleOfUnit  <> 411000 and u.PrimaryRoleOfUnit <> 411005)

    I believe the OR is your problem, when it is either of these 2 values the other side of the OR is TRUE so the value gets returned. Try the AND like I posted above.

    Add comment
    10|10000 characters needed characters exceeded