"NULL"  can be defined as, "A missing unknown value" that is not  equal to any values such as 0,1 or empty.

Though it refers "No value", we cannot use an empty string to select columns that contains null. If you provide any default value for a null column at the time of table definition, that value will be stored instead of 'NULL'.  MySql provides IS NULL and IS NOT NULL operators to work with null values.

To select a row which contains null value, we can use IS NULL operator. Example,
Select * from products where name IS NULL;

For rows that doesn't contains null values we can use IS NOT NULL.
In General, you can use null columns wherever possible. But it is harder for MySql to optimize queries that refers null columns. A nullable column uses more storage space and it needs special calculations inside MySql, So its good to avoid using NULL columns otherwise if your applications really needs it


Comments (0)
Leave a Comment

loader Posting your comment...