
How to use the SQL IS NULL Condition
How to use the SQL IS NULL Condition
Learn how to use the SQL IS NULL Condition to test for a NULL value in SQL. This tutorial explains what a NULL value is and demonstrates how to write a query using the IS NULL Condition with an easy to follow example.
SQL IS NULL Condition (and sample data):
https://www.techonthenet.com/sql/is_n…
SQL Tutorials:
https://www.techonthenet.com/sql/inde…
Don’t forget to subscribe to our channel for more great SQL tutorials!
Visit us at: https://www.techonthenet.com
or follow us on:
Facebook: https://www.facebook.com/techonthenetcom
Twitter: https://twitter.com/tech_on_the_net
Pinterest: https://www.pinterest.com/techonthene…
Content
0.03 -> The IS NULL condition is used in SQL
to test for a NULL value
5.63 -> Before we get started, let's first
explain what a NULL value is
10.12 -> NULL is a special value in SQL
12.96 -> While sometimes NULL is confused
with an empty string
16.32 -> NULL is actually the absence of a value
19.08 -> NULL are not only found in
character or string columns
22.68 -> They can also be found in other datatype columns
such as numeric or date
27.32 -> but you can only use a NULL
value in a column that allows NULLs
30.98 -> as defined by the CREATE TABLE statement
33.74 -> So to test for a NULL value can be very tricky
36.98 -> You can't simply just say
= NULL or != NULL
41.14 -> Instead you need to use a special condition
called IS NULL
45.28 -> The IS NULL condition tests an expression
and returns TRUE if a NULL value is found
51.04 -> otherwise it returns FALSE
53.086 -> It can be used in the SELECT, INSERT,
UPDATE or DELETE statement
57.56 -> Now that you understand what a NULL is
60.22 -> let's cover an example of how to use
the IS NULL condition
64.18 -> Here we have a table called customers
containing the following data
68.52 -> Notice that there is one record in the table where
the favorite_website column is NULL
73.92 -> Let's write a SELECT statement that returns this record
77.4 -> We'll start by entering
SELECT * FROM customers
81.14 -> to let the database know that we want to return
all columns from the customers table
86.16 -> The WHERE clause is next
88.36 -> This is where we will enter our
IS NULL condition
91.76 -> Since we want to return only those records where
the favorite_website is NULL
96.46 -> we will enter the following
102.8 -> Now let's run our SELECT statement
and see what results we get
106.48 -> As you can see, our SELECT query
returns only the one record
110.12 -> where there is a NULL value in
the favorite_website column
113.84 -> This covers a simple example of how
to use the SQL IS NULL condition
118.42 -> If you would like to see more examples
121.1 -> or would like to download the sample data
we used for this tutorial
124.44 -> please visit our website at
TechOnTheNet.com
127.34 -> You can also try the examples
in our SQL editor on our website
131.6 -> Look for the "TRY IT" button
next to each example
134.95 -> If you found our tutorial helpful,
please leave a like on this video
139.02 -> and don't forget to subscribe to our
YouTube channel for more great SQL tutorials
Source: https://www.youtube.com/watch?v=DUGppOtEX-s