mysql  null values

the null value means "a missing unknown value".

by default, every table column can hold null values.to text for null use the is null and is not null operator.

it is not possible to test for null values with comparison operators, such as <, >, = or <>.


mysql is null operator

the is null operator always used to look for null value.

how do we check each column with null value in a table?

in this condition we always use the is null operator with column name in where clause.

                 select    userid,   firstname   

                 from     users
                 
                 where    salary   is null;

output : try it yourself


mysql is not null operator

how do we check each column with no null value in a table?

in this situation we use the is not null operator.

                 select    userid,   firstname   

                 from     users
                 
                 where    salary   is not null;

output : try it yourself.


mysql  not null  constraint

the not null constraint enforces a column to not accept null values.

the following mysql enforces the "userid" and "salary" column to not accept null values:

         create table      user
 
                           (
                           
                            userid   int(10)  not null, auto_increment,
                            
                            firstname    varchar(255),
                            
                            lastname     varchar(255),
                            
                            salary  int not null
                            
                            );

table describes