1 00:00:00,120 --> 00:00:05,370 Next up, we're going to talk about some logical operators that are built into MySQL that help us write 2 00:00:05,370 --> 00:00:09,180 more complex queries and more complicated logic. 3 00:00:09,720 --> 00:00:16,230 For example, a simple thing that we could do by the end of this section is select all the books not 4 00:00:16,230 --> 00:00:17,940 published in 2017. 5 00:00:18,090 --> 00:00:23,520 We know how to publish or select books published in 2017, but what about the opposite? 6 00:00:24,240 --> 00:00:28,620 Or select all birthdays between 1990 and 1992? 7 00:00:28,800 --> 00:00:35,060 Or select all the items that are in stock and also have a price under 1999. 8 00:00:35,070 --> 00:00:39,360 So these are still relatively simple, but there's building blocks that we're going to cover things 9 00:00:39,360 --> 00:00:45,090 like not and between and and so we'll get there. 10 00:00:45,120 --> 00:00:48,030 We're going to start in this video with not equal. 11 00:00:48,360 --> 00:00:52,890 So an exclamation point in front of the equal sign means not equal. 12 00:00:53,340 --> 00:01:00,510 In this example, I'm selecting the title from books where the year is not 2017. 13 00:01:00,870 --> 00:01:10,950 So of course we know how to do select star from books where I think it's released year is equal to what 14 00:01:11,010 --> 00:01:12,450 did I say, 2017. 15 00:01:12,450 --> 00:01:13,190 There we go. 16 00:01:13,200 --> 00:01:15,630 Lincoln in the Bardo 2017. 17 00:01:15,660 --> 00:01:23,490 There's one book Row 19 But if I put an exclamation point in front of that equal sign, that now means 18 00:01:23,490 --> 00:01:24,750 not equal. 19 00:01:24,960 --> 00:01:31,050 So we'll select any books where release year is anything but 2017. 20 00:01:31,050 --> 00:01:38,460 So we get a bunch of them, as you can see here, but we won't have 2017, so we're missing that row. 21 00:01:38,490 --> 00:01:41,880 It might be a little harder to tell, but why don't we try another example? 22 00:01:41,880 --> 00:01:50,670 Let's select title and author, last name from books, and let's select all the books that were not 23 00:01:50,670 --> 00:01:53,940 written by Gaiman, Neil Gaiman. 24 00:01:53,940 --> 00:01:55,620 So we'll just use the last name. 25 00:01:55,950 --> 00:02:02,730 So I would do something like select title and author, last name from books where author L name. 26 00:02:02,730 --> 00:02:07,920 And instead of saying it's equal to Gaiman, of course that's going to give me Neil Gaiman's three books. 27 00:02:07,920 --> 00:02:11,490 Oh, I spelled it wrong, gay man like that. 28 00:02:11,490 --> 00:02:17,940 GAIMAN Instead of that, we're going to just put an exclamation point to invert the meaning of this. 29 00:02:17,940 --> 00:02:23,880 Now, again, author last name can be anything except Neil Gaiman or just Gaiman. 30 00:02:23,880 --> 00:02:27,930 And we see all of the books, minus the Gaiman books. 31 00:02:27,930 --> 00:02:30,660 So there's a smaller group. 32 00:02:30,660 --> 00:02:35,550 You still just have to kind of trust that it works, but you can see there's no Gaiman here versus here. 33 00:02:35,550 --> 00:02:39,540 You know, we had Gaiman, Gaiman and Gaiman there. 34 00:02:39,540 --> 00:02:42,030 So that's our first example of a logical operator. 35 00:02:42,030 --> 00:02:48,240 We've actually already seen a quality which is a logical operator as well, the single equal sign. 36 00:02:48,690 --> 00:02:53,460 But when we put that bang in front of it or the exclamation point, it means not equal. 37 00:02:53,880 --> 00:02:56,820 So next step, we're going to keep learning some more of these operators.