SQL query for nonnull records only

Asked

Viewed 14,121 times

5

I have a table NotasFiscais and I’m searching all the records it contains in the column NChave. But some result contains this information and others do not, in the case are as NULL. How could I bring only 'true records'' ?

2 answers

10

Null is not a value, you need to use IS NULL to find null or void IS NOT NULL not null at the time of comparison. It should look something like:

SELECT * FROM NotasFiscais WHERE NChave IS NOT NULL

Recommended reading:

What NULL Really Means?

  • Got it, thanks for the guidance. And your statement met my need.

  • @Igorcarreiro do not forget to mark this answer as your problem solver.

5

Null is a result that does not return any value so it cannot be compared by operators as = or != , for this you must use IS NULL to find NULL and IS NOT NULL to find values that are not NULL.

SELECT * FROM table WHERE field IS NOT NULL

Browser other questions tagged

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