In this chapter, we explore two important concepts in SQL: *Null values* and *Update
statements*. These concepts are fundamental for handling missing data and modifying
existing records in relational databases.
---
*Null Values in SQL*
A *Null* value in SQL represents unknown or missing data. It is not the same as an empty
string or zero; it indicates that the value is absent or undefined.
*Null in a Table:*
For example, consider a table storing student information. Some students might not have a
phone number. Instead of using an empty string or incorrect data, we use *Null* to indicate
the absence of a value.
*Behavior of Null in Comparisons:*
Null behaves differently during comparisons. For instance, comparing a value with Null, like
`5 = NULL`, will not return a boolean result (TRUE or FALSE). Instead, it will return *Null*
because Null is not comparable to any value.
To check for Null values, SQL provides the *IS NULL* and *IS NOT NULL* operators. Here's
an example to find records where the phone number is missing:
```sql
SELECT * FROM Students
WHERE PhoneNumber IS NULL;
```
*Null and Arithmetic Operations:*
When Null is involved in arithmetic operations, the result will always be Null. This behavior is
important to understand, as it can affect calculations. For example:
```sql
SELECT 5 + NULL, 3 * NULL, 7 / NULL;
```
In this case, all of the expressions will return *Null*, as any operation with Null results in Null.
---
*Update Statements in SQL*
The *UPDATE* statement is used to modify existing data in a table. It allows you to change
one or more values in a record based on a condition.