SQL isnull() function is used find null value in rows and returns 0 (zero) on if null value found in column from database table name, otherwise if column value is not null it will return 1 value. null value will replace automatically with zero value.
SQL isnull() query example explains how to use isnull() query in SQL.
Table class_name with all records without desired column name sorting
+---------+-------------+------------+------------+ | Roll_No | Name | Class_Name | Year_Start | +---------+-------------+------------+------------+ | 1 | Amit Mishra | B.Science | 2005 | | 2 | Robot | B.Tech | 2005 | | 3 | Rohan | M.Tech | 2005 | | 4 | Vivek | B.Tech | 2009 | | 5 | Chander | B.Science | 2009 | | 6 | Deepak | B.Science | 2009 | | 7 | Gagan Deep | B.Tech | NULL | | 8 | Mohit Garg | M.Tech | NULL | +---------+-------------+------------+------------+
isnull() examples
SELECT Name, Year_Start, ISNULL(Year_Start) FROM class_name c;
Output
+-------------+------------+--------------------+ | Name | Year_Start | ISNULL(Year_Start) | +-------------+------------+--------------------+ | Amit Mishra | 2005 | 0 | | Robot | 2005 | 0 | | Rohan | 2005 | 0 | | Vivek | 2009 | 0 | | Chander | 2009 | 0 | | Deepak | 2009 | 0 | | Gagan Deep | NULL | 1 | | Mohit Garg | NULL | 1 | +-------------+------------+--------------------+




Link to Us