Updating NULL Values in a Table
We can update the NULL values present in a table using the UPDATE statement in SQL. To do so, we can use the IS NULL operator in the WHERE clause to select the rows with NULL values and then we can set the new value using the SET keyword.
Let’s suppose that we want to update SSN in the row where it is NULL.
Query:
UPDATE Employee SET SSN = '789-01-2345' WHERE Fname = 'Aditya' AND Lname = 'Arpan'; select* from Employee;
Output:
NULL values in SQL
In SQL there may be some records in a table that do not have values or data for every field and those fields are termed as a NULL value.
NULL values could be possible because at the time of data entry information is not available. So SQL supports a special value known as NULL which is used to represent the values of attributes that may be unknown or not apply to a tuple. SQL places a NULL value in the field in the absence of a user-defined value. For example, the Apartment_number attribute of an address applies only to addresses that are in apartment buildings and not to other types of residences.
So, NULL values are those values in which there is no data value in the particular field in the table.