SQL query only for non-null records

3

I have a NotasFiscais table and am fetching all the records it contains in the NChave column. However some results contain this information and others do not, in this case they are NULL . How could I bring only 'true' records?

    
asked by anonymous 18.04.2017 / 22:02

2 answers

7

Null is not a value, you must use IS NULL to find nulls or IS NOT NULL for non-nulls at the time of the comparison. Should be something like:

SELECT * FROM NotasFiscais WHERE NChave IS NOT NULL

Recommended reading:

What does NULL really mean?

    
18.04.2017 / 22:05
3

Null is a result that returns no value so it can not be compared by operators like = or! =, for this you should use IS NULL to find NULL values and IS NOT NULL to find values that are not NULL.

SELECT * FROM table WHERE field IS NOT NULL
    
18.04.2017 / 22:40