This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

how to include multiple values in WHERE clause

i am looking for the syntax to be able to include multiple values in a where clause for example.

SELECT InterfaceID

FROM Orion.NPM.Interfaces

WHERE InterfacesID != '4016',  '3011'

this will throw and error of course the desired result can be achieved using:

Where InterfaceID != '4016' AND InterfaceID != '3011'

however this will be far from optimal if scaled out to a large number to exclude.

many thanks

  • SELECT InterfaceID

    FROM Orion.NPM.Interfaces

    WHERE InterfaceID NOT IN (4016,3011)


    or perhaps more useful if dynamic need...

    SELECT InterfaceID

    FROM Orion.NPM.Interfaces

    WHERE InterfaceID NOT IN (

         SELECT InterfeaceID FROM Interfaces where <dynamic WHERE criteria here>

         )