O'Reilly logo

SQL: Visual QuickStart Guide by Chris Fehily

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

List Filtering with IN

Use IN to determine whether a given value matches any value in a specified list. The IN condition’s important characteristics are:

  • IN works with character strings, numbers, and datetimes.

  • The IN list is a parenthesized listing of one or more comma-separated values. The list items needn’t be in any particular order.

  • IN is a convenient, shorthand clause. You can replicate its behavior by using OR:

    WHERE test_column IN
          (value1, value2, value3)
    

    is equivalent to:

    WHERE (test_column = value1)
       OR (test_column = value2)
       OR (test_column = value3)
    
  • String comparisons may be case-insensitive or case-sensitive, depending on your DBMS; see the DBMS Tip in “Filtering Rows with WHERE” earlier in this chapter.

  • You can negate an IN condition ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required