Compare different value, value "null" does not enter the resutaldo

Asked

Viewed 82 times

0

I have a table of files, and in it there is a field called "document type", which is filled with 1 or when it is not filled is NULL, the problem is that when I give a SELECT and use the comparator to return all results with document type other than 1 (AND tipo_documento <> 1), data that has NULL is not returned, because this occurs?

The way I found to get around it was like this:

AND tipo_documento <> 1 OR tipo_documento IS NULL
  • The NULL value means that the data value for the column is unknown. An unknown value cannot be compared with another value. Use the IS NULL or IS NOT NULL clauses to test a NULL value.

1 answer

0

What kind of camp?

It was really only supposed to work with AND tipo_documento IS NULL.

  • It is because it may have other values, but why only different than 1 is not enough?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.