text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
It's not in our database.
1,955.48
2.29
We can actually put together a condition around this idea of null, something
1,957.77
4.52
not being there.
1,962.29
1.71
We could use IS NULL to figure out if a value is null.
1,964
3.57
It's not there.
1,967.57
0.658
It's missing from our database.
1,968.228
1.292
Or IS IT NULL, meaning that it actually is there.
1,969.52
4.763
So I'll go back to SQLite and show you what we could
1,974.283
2.167
do with some of these concepts here.
1,976.45
3.52
Let me go back to my terminal.
1,979.97
1.43
And let's say I do want to find those translators that
1,981.4
3.12
don't exist in my database.
1,984.52
2.08
Well, I could use SELECT, let's say, "title" and "translator" from my
1,986.6
6.8
"longlist."
1,993.4
1.05
And I want to make sure that these translators are null--
1,994.45
4.11
they don't exist.
1,998.56
1.36
So I'll say WHERE "translator" IS NULL Semicolon.
1,999.92
5.33
Now, I'll hit Enter.
2,005.25
1.53
And I should see two books.
2,006.78
1.438
Titles are The Perfect Nine and the indictment of The Enlightenment
2,008.218
2.792
of The Greengate Tree.
2,011.01
0.917
But notice how over here, this value is null--
2,011.927
3.403
it doesn't exist in my table.
2,015.33
2.74
I could conversely find those books that do have translators using IS NOT NULL.
2,018.07
5.27
And I will try this one again.
2,023.34
2.71
But in this case, I'll say, WHERE "translator" IS NOT NULL Semicolon.
2,026.05
7.85
And I'll hit Enter.
2,033.9
1.77
And now, let me just zoom out a little bit.
2,035.67
2.67
I can see that I have both titles on the left-hand side
2,038.34
5.13
and translators on the right-hand side.
2,043.47
2.31
All of these actually exists.
2,045.78
2.26
These are books that did have translators in this case.
2,048.04
3.679
So a good way to find data that's missing in your table using
2,051.719
3.091
NULL or IS NOT NULL.
2,054.81
2.822
So let's come back over here and figure out what more
2,057.632
2.208
we can do with some of these queries.
2,059.84
2.67
We've kind of exhausted our work with some of our conditions,
2,062.51
4.95
like chaining them together and using NULL and so on.
2,067.46
2.35
But one more thing we could do is trying to use this idea of matching
2,069.81
4.73
some kind of pattern in my database.
2,074.54
2.349
So maybe I'm a book reader.
2,076.889
3.591
And I want to find a book with the word "love" somewhere in the title.
2,080.48
3.989
Well, for this, I could use another keyword--
2,084.469
2.551
this one called LIKE.
2,087.02
2.25
So LIKE is a good keyword to use when I want to roughly match
2,089.27
5.159
some string in my database.
2,094.429
2.281
Let's say I want to look at book titles and find
2,096.71
2.43
if some word exists in that title.
2,099.14
2.52
I could use LIKE for that.
2,101.66
2.41
And LIKE becomes powerful when you combine it
2,104.07
2.36
with these other operators, namely this percent sign and this underscore.
2,106.43
4.4
The percent sign can match any character around a string I give it.
2,110.83
4.78
And the underscore can match any single character
2,115.61
3
that I pass in with my string.
2,118.61
2.37
It's probably best shown with an example.
2,120.98
2.47
So let me show you some in my terminal here.
2,123.45
2.81
I'll walk back.
2,126.26
1.05
And, again, we'll try to find these books that
2,127.31
2.07
have "love" somewhere in the title.
2,129.38
2.85
So I'll say in this case, SELECT, let's say, "title" from "longlist."
2,132.23
5.97
But I don't want all titles.
2,138.2
1.68
I only want those that have "love" somewhere in this title.
2,139.88
4.06
So I'll say WHERE "title" LIKE, let's say, percent love percent Semicolon.
2,143.94
9.71
Now before I run this, let me explain what this is doing.
2,153.65
3.99
I have here a SELECT query asking for the "title"
2,157.64
3.96
column from my "longlist" table.
2,161.6
3
But I'll only get back those rows where "title" is LIKE percent love percent.
2,164.6
6.51
But what does that mean?
2,171.11
1.42
Well, the percent, remember, matches any string of characters.
2,172.53
3.8
It could match a, b, c, 1, 2, 3.
2,176.33
2.25
As long as any string of characters comes after and has "love,"
2,178.58
3.69
I could match that value here.
2,182.27
3.19
Similarly, the percent sign after says anything
2,185.46
2.585
that comes after "love," as long as "love" is somewhere in the middle.
2,188.045
4.585
So anything before, anything after, but so long as "love"
2,192.63
3.59
is just somewhere in there, I'll get it back.
2,196.22
2.31
So let me try that running this query then and come back over here.
2,198.53
3.75
I will hit Enter on my query.
2,202.28
2.25
And I'll see I get back four books--
2,204.53
2.52
Love in the Big City, More Than I Love My Life and so on.
2,207.05
4.06
So notice how if I come back over here that each of these titles
2,211.11
3.77
has "love" somewhere in it.
2,214.88
1.83
For this one, I match love up front and then
2,216.71
3.42
had any string of characters coming after it like this.
2,220.13
2.8
For this one, I had More Than I Love My Life.
2,222.93
2.75
I got some string before it.
2,225.68
1.71
And then afterwards, any string after it, "love" is somewhere in the middle.
2,227.39
5.19
Let me show you another example too, where
2,232.58
2.07
we use percent in a different way.
2,234.65
2.71
Let's say I want to find only those books that
2,237.36
2.51
have "The" at the very beginning of the title.
2,239.87
3.45
Let me try this.
2,243.32
1.09
I'll say a SELECT "title" from "longlist" then WHERE,
2,244.41
6.47
let's say, the "title" is LIKE the percent Semicolon.
2,250.88
9.08
Now, I've changed something up.
2,259.96
1.9
I have not percent in front and behind, but only after the "The."
2,261.86
5.9
So in this case, I'll get back not anything
2,267.76
2.91
that has "The" the title wherever, but now
2,270.67
3
at the very beginning of this string.
2,273.67
2.94
And I see perhaps a style mistake.
2,276.61
3.03