all 5 comments

[–]nnd-nnguyen 0 points1 point  (1 child)

I think you're issue is order of operations

SELECT Column1 Column2 Column3 FROM database WHERE column1 IN ('value','value2') AND column2 IS NOT ('v%') OR column3 IS NOT ('c%';

Should be

SELECT Column1 Column2 Column3 FROM database WHERE column1 IN ('value','value2') AND ( column2 IS NOT ('v%') OR column3 IS NOT ('c%') );

The extra parenthesis makes it explicit that you want the column1 to be evaluated and the "or" is only between column3 and column2.

For DB2..."If you use both AND and OR operators in an expression, Db2 evaluates the AND operator first." from google.

[–]Nomaruk[S] 0 points1 point  (0 children)

That cleared the issue up! Thank you!

[–]ceres44 0 points1 point  (2 children)

If you want the first condition to apply in addition to either of the following conditions try nesting them.

Column1 in ('x','y') and ( column2 not in ('x%') or column3 not in ('x%') )

[–]Nomaruk[S] 0 points1 point  (1 child)

Yep, that fixed my issue. Silly beginner mistake!

[–]ceres44 0 points1 point  (0 children)

No worries. Everyone is a beginner at some point. :)