Contents
SQL NULL Values: Main Tips
- This value defines lost data.
- Tables already contain NULL values.
- NULL is handled not like other values.
SQL Working with NULL Values
Below there is a table called "People":
ID | Last_Name | First_Name | Address | City |
---|---|---|---|---|
1 | Bob | Bola | Nesdan | |
2 | Bill | Bove | Ergan 13 | Nesdan |
3 | Benny | Bari | Nesdanger |
Hypothetically the "Adress" column is optional. Then when you write a data record without a value assigned it will receive NULL.
Testing is unavailable using default operators, that's why we use IS NULL/IS NOT NULL.
![DataCamp DataCamp](https://assets.bitdegree.org/online-learning-platforms/storage/media/datacamp-logo-5f96bfc70113e.o.png)
Pros Main Features
- Easy to use with a learn-by-doing approach
- Offers quality content
- Gamified in-browser coding experience
- The price matches the quality
- Suitable for learners ranging from beginner to advanced
- Free certificates of completion
- Focused on data science skills
- Flexible learning timetable
![Udacity Udacity](https://assets.bitdegree.org/online-learning-platforms/storage/media/udacity-review-logo-small.o.png)
Pros Main Features
- Simplistic design (no unnecessary information)
- High-quality courses (even the free ones)
- Variety of features
- Nanodegree programs
- Suitable for enterprises
- Paid Certificates of completion
![edX edX](https://assets.bitdegree.org/online-learning-platforms/storage/media/edx-logo-60190648f3a51.o.png?tr=w-200)
Pros Main Features
- A wide range of learning programs
- University-level courses
- Easy to navigate
- Verified certificates
- Free learning track available
- University-level courses
- Suitable for enterprises
- Verified certificates of completion
IS NULL: Example
To select NULL data records we use IS NULL operator:
Example
SELECT col_names
FROM tbl_name
WHERE col_name IS NULL;
IS NOT NULL: Example
To select data records with no NULL values we use IS NOT NULL operator:
Example
SELECT col_names
FROM tbl_name
WHERE col_name IS NOT NULL;
Example
SELECT Name, Price
FROM Products
WHERE Unit_On_Order IS NOT NULL;