I thought NOT IN
behaves the same as !=
in a query. But a query using !=
returns more rows than a query using NOT IN
:
SELECT count(A.NO)
FROM A
WHERE
A.CODE != 'a'
AND
A.CODE != 'b'
AND
A.CODE != 'c'
AND
A.NAME != 'd'
AND
A.NAME != 'e'
returns 1566 rows, whereas
SELECT count(A.NO)
FROM A
WHERE
A.CODE NOT IN ('a','b','c')
AND
A.NAME NOT IN ('d','e')
returns only 1200 rows.
I suppose NOT IN
excludes NULL
values - would that be the only difference?
I have tried to replecate the problem using this simplified SQL fiddle, however, it returns the same number for both versions.
What is differant about your data?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With