1 00:00:00,800 --> 00:00:02,029 Welcome back. 2 00:00:03,570 --> 00:00:07,530 So in this section, we're going to focus on what are called logical operators. 3 00:00:08,250 --> 00:00:13,170 Actually, we're focusing on operators in general, and most of the ones we're going to work with are 4 00:00:13,170 --> 00:00:14,040 logical operators. 5 00:00:14,040 --> 00:00:15,650 That distinction doesn't really matter, though. 6 00:00:15,660 --> 00:00:22,650 I'm just going to call them all logical operators, and they allow us to add logic into our SQL statements. 7 00:00:22,650 --> 00:00:28,350 So up until this point, we've seen things like well, like, like which allows us to select things 8 00:00:28,350 --> 00:00:34,620 based off of text looking or containing certain strings, matching patterns. 9 00:00:34,920 --> 00:00:41,640 We've seen how to do things where we can check, select all books where the title is exactly Lincoln 10 00:00:41,640 --> 00:00:45,330 in the Bardo or where released year is exactly 2013. 11 00:00:45,600 --> 00:00:51,750 But there's a whole slew of other things that we'd like to be able to select based off of, and that's 12 00:00:51,750 --> 00:00:53,370 what we're going to focus on in this section. 13 00:00:53,370 --> 00:00:58,950 So we're going to see how to do things like select all books not published in 2017. 14 00:00:59,220 --> 00:01:01,260 Right now, we don't have a way of doing that. 15 00:01:02,400 --> 00:01:06,840 Or what about select all birthdays between two different dates? 16 00:01:06,840 --> 00:01:14,550 So not just all birthdays that are exactly, you know, April 22nd, 1990 or 1992 or whatever it is, 17 00:01:14,550 --> 00:01:16,800 but between those two dates. 18 00:01:18,370 --> 00:01:20,020 Or select all items. 19 00:01:20,020 --> 00:01:28,240 So this is some table I made up called items, all items that are in stock and price below 1999. 20 00:01:28,240 --> 00:01:29,680 So that's two different things. 21 00:01:29,680 --> 00:01:35,020 We know how to select all items that are in stock, but there is a second component, which is not only 22 00:01:35,020 --> 00:01:38,980 do they need to be in stock, but they need to be priced below 1999. 23 00:01:39,040 --> 00:01:41,560 And right now we don't know how to do that either. 24 00:01:41,650 --> 00:01:46,600 With that lengthy introduction out of the way, let's take a look at some of our first ones. 25 00:01:46,600 --> 00:01:50,470 So the actual first one we're going to look at is called not equal. 26 00:01:50,680 --> 00:01:54,940 And it looks like this exclamation point and an equal sign. 27 00:01:55,330 --> 00:01:58,510 So we've seen how to do things using equal sign, right? 28 00:01:58,510 --> 00:02:00,610 We've done select. 29 00:02:01,540 --> 00:02:08,830 Let's do title comma released here from books where and let's do release here. 30 00:02:08,830 --> 00:02:12,580 So we're released here is exactly 2017. 31 00:02:13,750 --> 00:02:16,720 So we've seen how to do this with equal sign. 32 00:02:16,960 --> 00:02:18,250 We've been doing it all the time. 33 00:02:18,250 --> 00:02:21,520 However, what if I want to do the opposite? 34 00:02:21,520 --> 00:02:26,140 I want all books that were released in any year, excluding 2017. 35 00:02:26,530 --> 00:02:31,240 So what we want to do is basically replace that equal sign with a not equals. 36 00:02:32,500 --> 00:02:38,590 So we could do this select title from books where year is not equal to 2017. 37 00:02:38,710 --> 00:02:43,570 If you're familiar with any programming languages, you've probably come across this not equals. 38 00:02:43,570 --> 00:02:46,900 It's a pretty universal way of of writing, not equals. 39 00:02:46,900 --> 00:02:48,370 So let's give it a shot. 40 00:02:49,690 --> 00:02:52,960 Recall this and just replace it with not equals. 41 00:02:54,590 --> 00:03:01,490 And now you can hopefully see that we get everything back except for Lincoln in the Bardo. 42 00:03:01,700 --> 00:03:07,280 And of course, if there was more than one book released in 2017, then we would get any book back or 43 00:03:07,280 --> 00:03:08,240 all books back. 44 00:03:08,240 --> 00:03:11,210 Except that those books from 2017. 45 00:03:12,350 --> 00:03:13,670 So we can see that it's gone. 46 00:03:13,910 --> 00:03:15,020 We could do the same thing. 47 00:03:15,020 --> 00:03:21,050 But instead of working with Release Year, what if we do it with author? 48 00:03:21,050 --> 00:03:23,950 So let me just start over here. 49 00:03:23,960 --> 00:03:32,390 Let's select title and author last name from books and we'll start just with all of them. 50 00:03:34,280 --> 00:03:41,580 And then let's select where the last name is exactly equal to Harris. 51 00:03:41,600 --> 00:03:43,340 So we have those two Harris's. 52 00:03:44,980 --> 00:03:45,740 Where. 53 00:03:46,480 --> 00:03:50,680 Author ll name equals Harris. 54 00:03:50,740 --> 00:03:51,490 Just like that. 55 00:03:52,810 --> 00:03:53,920 And we get those, too. 56 00:03:54,340 --> 00:03:58,720 And by just flipping the switch here, that exclamation point. 57 00:03:59,510 --> 00:04:05,130 We now get everything except those two, so hopefully you get the point by now. 58 00:04:05,150 --> 00:04:08,480 Not equals works like you would expect. 59 00:04:08,810 --> 00:04:13,160 If you're not familiar with the exclamation point, it might take a little bit of getting used to, 60 00:04:13,160 --> 00:04:15,980 but otherwise it's pretty straightforward. 61 00:04:16,220 --> 00:04:17,720 It's the opposite of equals. 62 00:04:18,230 --> 00:04:18,769 Awesome. 63 00:04:18,769 --> 00:04:21,800 So that's the first one that we're taking a look at, but we have quite a few more. 64 00:04:21,950 --> 00:04:26,300 Next up, we're going to talk about something very similar, which is not like.