1
00:00:00,090 --> 00:00:06,360
We have one last very simple comparison function or operator actually that I'm going to show you, and

2
00:00:06,360 --> 00:00:08,280
it has to do with null values.

3
00:00:08,880 --> 00:00:15,780
So right now I have some null values in my books table like, well, these rows here have no author.

4
00:00:16,170 --> 00:00:18,450
How would I target those rows?

5
00:00:18,480 --> 00:00:24,360
Let's say I want to delete them or I want to just select them like select star from books.

6
00:00:25,230 --> 00:00:28,290
Let's say where the author last name is null.

7
00:00:28,650 --> 00:00:31,980
Well, it does not work to do this equals null.

8
00:00:32,920 --> 00:00:34,330
I don't get anything back.

9
00:00:34,720 --> 00:00:40,420
So instead of that, I have to use a special operator called is null.

10
00:00:40,450 --> 00:00:46,510
We also have is not null and this is set up to work specifically with null values.

11
00:00:46,690 --> 00:00:52,000
So instead of saying where all the last name is, equal sign no I'll say is null.

12
00:00:52,570 --> 00:00:59,980
And now we find all of the books that have no last name, where the last name is set to no great.

13
00:01:00,220 --> 00:01:01,680
I also have is not null.

14
00:01:01,690 --> 00:01:03,710
So same thing, but opposite.

15
00:01:03,810 --> 00:01:08,320
Now I'm getting back all the books that do have another last name that is not.

16
00:01:08,320 --> 00:01:08,950
No.

17
00:01:09,670 --> 00:01:16,540
So I guess we could end by deleting all of the books that have no author, last name or no title.

18
00:01:16,810 --> 00:01:21,910
And again, the way that I like to do that is by starting with a selection, select what I'm trying

19
00:01:21,910 --> 00:01:23,160
to delete and then delete.

20
00:01:23,170 --> 00:01:25,130
So select star from books.

21
00:01:25,150 --> 00:01:30,220
Where are we going to do title is null or last name?

22
00:01:30,280 --> 00:01:31,210
Let's do title.

23
00:01:31,210 --> 00:01:33,340
So I have two books that have no title.

24
00:01:33,550 --> 00:01:34,630
Let's delete them.

25
00:01:34,630 --> 00:01:39,730
So instead of select star from books where title is null, I'm going to do delete.

26
00:01:42,930 --> 00:01:48,390
From books where title is null and it says two rows affected.

27
00:01:48,390 --> 00:01:51,660
If I try and select those rose again, they're gone.

28
00:01:51,750 --> 00:01:55,530
So just a quick example of using is null and is not null.

29
00:01:55,920 --> 00:02:00,510
We can't directly compare using the equal sign to null or not equals.

30
00:02:00,510 --> 00:02:01,980
Really we need to use is null.

31
00:02:01,980 --> 00:02:03,120
End is not null.

