Reputation: 113
I'd like to double-check this:
If you're using a WHERE clause with the NOT IN condition, and you only have one single criteria, do you have to leave that criteria in brackets?
So in the clause below if Y and Z were removed, would X have to remain in brackets (see the second WHERE NOT IN CLAUSE
below).
WHERE LastEditedBy NOT IN ('X','Y','Z')
WHERE LastEditedBy NOT IN ('X')
Upvotes: 0
Views: 62
Reputation: 191235
The syntax diagram in the documentation shows the parentheses as required, but it does work without them:
select * from dual where dummy not in 'Y';
DUMMY
-----
X
and
select * from dual where dummy in 'X';
DUMMY
-----
X
both return data.
Including the parentheses anyway doesn't really cost you anything, keeps you in line with the official syntax (and as @jarlh noted, relying on undocumented behaviour isn't wise), will perhaps be a bit less confusing for someone else looking at your code, and will make future maintenance slightly easier if you need to add more values to the list later.
Upvotes: 6