AP 17 - Use IN / NOT IN for multiple OR operators

Severity

Warning Caution

Type

Readability

Problem

Chaining multiple OR operators makes SQL code less readable

SELECT col1
  FROM t1
 WHERE c1=9
    OR c1=5
    OR c1=10

Solution

Use the IN / NOT IN operator instead of chaining OR operators. It makes your SQL code more readable.

SELECT col1
  FROM t1
 WHERE c1 IN(9
          ,5 
          ,10)

Legitimate use of the anti pattern

None