text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
Well, for that, we could use this next SQL keyword, this one called WHERE.
1,305.81
4.92
So WHERE allows me to get back not all rows, but only
1,310.73
6.15
some rows where some condition is true.
1,316.88
4.09
So WHERE is often combined with other conditions
1,320.97
3.53
to make sure I only get back some rows, where that condition is true.
1,324.5
5.23
Let's try looking at that in SQLite to get
1,329.73
2.12
a feel for what it can do for us here.
1,331.85
2.32
So I'll go back to my WHERE.
1,334.17
3.38
And I will then go back to SQLite here.
1,337.55
3.06
Hit Control-L to clear my terminal.
1,340.61
2.88
And I'll then try this query.
1,343.49
2.04
I'll say SELECT "title."
1,345.53
3.27
SELECT "title."
1,348.8
0.99
And why don't we also select author along the way?
1,349.79
2.67
Two columns here.
1,352.46
1.83
And I'll select them from my longlist table.
1,354.29
3.09
But I don't want all rows.
1,357.38
2.07
I only want, let's say, those titles and authors that were longlisted in 2023.
1,359.45
5.79
So I'll do this.
1,365.24
1.02
I'll say WHERE the "year" column is equal to 2023.
1,366.26
6.81
And notice here how 2023 is not in quotes because it
1,373.07
3.81
is an actual number, an integer.
1,376.88
2.23
So I don't need to quote it like I would a string some collection of characters
1,379.11
3.5
or a table or column name.
1,382.61
3.1
So I'll hit Enter here.
1,385.71
1.77
And what do I see?
1,387.48
0.89
Well, I see only those books that were nominated in 2023.
1,388.37
4.5
Let's try this again.
1,392.87
1.33
I might try not just 2023--
1,394.2
2.93
I might try 2022 like this.
1,397.13
3.39
Hit Semicolon.
1,400.52
1.35
Now, I'll see those books nominated in 2022.
1,401.87
3.51
I could keep going.
1,405.38
1.12
I could say why not 2022?
1,406.5
1.76
Why not 2021?
1,408.26
1.56
Now, I have all those books nominated in 2021.
1,409.82
4.63
So this is handy.
1,414.45
2.59
We can set things equal to or not equal to make some condition here.
1,417.04
3.89
And we also have others we could use.
1,420.93
2.04
We saw equals just now.
1,422.97
1.68
But we similarly have not equals.
1,424.65
2.31
And we have this kind of obscure operator down here.
1,426.96
3.21
This one being also equivalent to not equals as we'll see in just a minute.
1,430.17
5.68
But let me first ask now, what questions do
1,435.85
2.27
we have on how to use WHERE or using SELECT so far?
1,438.12
4.05
SPEAKER: Why are the subsets of SQL?
1,442.17
2.59
CARTER ZENKE: A good question.
1,444.76
1.25
Are there subsets of SQL?
1,446.01
1.72
So there are.
1,447.73
1.43
In fact, S-Q-L or SQL was defined by the,
1,449.16
3.71
I believe it's the ANSI, like standard corporation.
1,452.87
2.14
They have a whole set of the SQL language
1,455.01
2.28
that is like the official version of it.
1,457.29
2.08
You might be able to use some subset of that version
1,459.37
2.87
with the database manager system that you actually use.
1,462.24
2.5
So for SQLite, we're using a subset of SQL that works with SQLite.
1,464.74
4.28
Similarly, if you were using another software like PostgreSQL or MySQL,
1,469.02
4.32
you could use another subset there too.
1,473.34
3.43
Let's take another question from Tayas, perhaps.
1,476.77
3.58
SPEAKER: Then I want to know that, can we add 2022 and 2021 in a terminal?
1,480.35
5.443
CARTER ZENKE: Yeah, good question.
1,485.793
1.417
Could I, perhaps, try to filter by 2021 and 2022?
1,487.21
5.67
I could do that.
1,492.88
0.702
And we'll see that in just a moment here.
1,493.582
1.708
So let's keep going and exploring some other options with not equals.
1,495.29
2.96
And then we'll see how we can combine conditions using WHERE too.
1,498.25
3.84
So let's go back, and let's focus first on trying
1,502.09
3.21
to use these not equal operators.
1,505.3
2.43
We saw the exclamation point equals and this greater than, less than sign put
1,507.73
4.65
together.
1,512.38
1.12
So let's try a few of those.
1,513.5
1.68
Let's say I want to find books that are written by a certain author.
1,515.18
4.89
Well, I could use equals for that.
1,520.07
1.55
But let's say I also want to find books that are not
1,521.62
2.55
written in the hardcover format, like they
1,524.17
2.64
tend to be more expensive and so on.
1,526.81
1.63
So I don't want hardcover books.
1,528.44
2.18
Well, I could try a query like this.
1,530.62
1.93
I could say SELECT "title" and "format," where format is either hardcover
1,532.55
5.54
or paperback, FROM my "longlist" table.
1,538.09
3.96
And now I'll say, WHERE the "format" is not equal to hardcover Semicolon.
1,542.05
7.32
So notice here I'm using single quotes for hardcover.
1,549.37
4.29
This is a string.
1,553.66
1.3
It's not a table name or a column name.
1,554.96
2.57
It is just a string.
1,557.53
1.05
So I'm using single quotes here.
1,558.58
2.19
Everything else, though, like format, longlist, title, et cetera,
1,560.77
4.23
those are all table names or column names.
1,565
3.4
So again, I'll hit Enter.
1,568.4
1.46
And now I'll see that these are all in paperback according to my table.
1,569.86
5.23
I've omitted those that are hardcover.
1,575.09
2.9
Well, I could also use in this case, the greater than or less
1,577.99
3.99
than sign put together to say not equals as well.
1,581.98
3.25
Let me just hit the Up Arrow on my computer
1,585.23
1.97
to reveal what I just previously typed.
1,587.2
2.34
I'll then tab back over and say not exclamation point equals, but less than
1,589.54
6.87
and then greater than.
1,596.41
1.26
Hit Enter now.
1,597.67
1.17
And I should see the very same results.
1,598.84
2.31
But all I did was change this operator from exclamation point
1,601.15
3.12