Null is used with a logical operator

I have a table with a name, age and address. I have only five rows of data in a table. For some strings, age remains null. I need to display all data in which age is not zero.

select * from sample_table where (age! = null);

But the conclusion is not output, and it also does not give an error. Please explain this. Thanks.

+3
source share
3 answers

With NULL, you must use ISor IS NOT. The following query should work:

SELECT * FROM sample_table WHERE (age IS NOT NULL)
+4
source

MySQL explanation

NULL SQL, , NULL - , string ''. .

SQL NULL , NULL. , NULL NULL

NULL, expr = NULL.

NULL, IS NULL.

+2

IS NULL NOT NULL.

NULL, ( !)

NULL

MySQL, Sybase, SQL Server...

+1

Source: https://habr.com/ru/post/1705698/


All Articles