S
S
Sergey2020-05-21 10:16:01
MySQL
Sergey, 2020-05-21 10:16:01

MySQL WHERE NOT IN skip NULL?

The table table has a status field which can be NULL.

SELECT * FROM `table` WHERE `status` NOT IN ('cancel', 'finished', 'failed');

This query will not return fields where status is NULL unless you explicitly specify OR status IS NULL.

Bug or feature?

The question is rather for your own understanding of the logic of such an implementation of the WHERE NOT IN condition.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Samsonov, 2020-05-21
@Ermak1

This is not a bug. Comparison with NULL gives undefined result, so you can't check equality/inequality with NULL by normal means

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question