 What's going on everybody? My name is Alex Freberg and in this video we're going to be going over the where statement and sequel. In the very first video we create our table, insert the data into our table. In the second video we went over the select and the from statement and now we are on to the where statements. Now what does the where statement do? It helps limit the amount of data and specify what data you want returned. We have a quite a few concepts that we're going to be covering today. Let's just start out with something really easy. Let's do where first name equals Jim. Really simple. So we're selecting everything where first name equals Jim and this is our output. So really really simple. Let's try where it does not equal. This right here says does not equal Jim and let's execute that. And as you can see we have everybody except Jim Halperd in there. So now let's look at the greater than or less than. So in this table I think the one that we're going to look at is age. So let's look at age. And let's do where it's greater than 30. And when we execute that we're going to get everyone who is over the age of 30. Now as you can see we're not including people who are 30 years old. Everyone include people who actually are 30 years old. We're going to add the equal sign right there. So we should be seeing people who are now 30. So before Pam and Jim were not in there and now they are. If we do the exact same thing, let's do less than 32. Here's everyone that's going to be included but if we want to include the people who are 32 year old then we are just going to add that equal sign and now the people who are 32 years old like Toby and Meredith are now included. If we want to go even further we want people who are less than or equal than 32 and who are male we can say we're gender equals male. So now we have two things that we are specifying that we need. We need someone whose age is less than 32 and we need their gender to be male. So let's execute that and we have four people who meet that criteria. So that's what the and statement does. If we write or then only one of these criteria has to be correct in order for it to be met. So if we hit execute now we're saying anybody who's under the age or equal to 32 or their gender equals male. So if we look down here Michael Scott is actually 35 years old so he's over 32 but since he is male he is now included. Let's get rid of everything really quick. I want to look at this like really quick. So let's execute just that and if you do that you highlight just that and hit execute then it will only run what you have highlighted. So now let's look at this whole table. Now when you're using like you typically are doing this for sometimes numerical but most of the time you're using it for text information. So if we're looking at this right here if I'm looking at last names and let's say I want everybody whose last name starts with s. You can't really do that with anything else. So I'm going to say where it's like and then I'm going to say s and after that I'm going to put a percent sign that's actually called a wild card and if I close that off what this is saying is is I want every last name where it starts with or where it's like where it only starts with an s. So let's run this really quick. Now we have two people whose last name start with s. Now if I put a wild card at the beginning we are now saying where there is an s anywhere in anybody's name. So let's execute this and see what we get. So now even if the s is like Flenderson towards the end it still counts. So you can specify multiple things in here as well. So let's say I wanted to start with s that would return shrewt and scott but now I want something that also has an o in it. So it has an s at the beginning and then somewhere in there there's an o. Now let's execute that and there's only one person that means that criteria. So you can do that for multiple things you can even say ott and let's execute that and he's still going to be returned and if we put c at the back it's not going to be returned because it follows it in order. So it is an s ottc the c would actually need to go over here. So now we have sc ott and although there's a bunch of wild cards in here it is going to return scott. So that is a little bit a little hint at how you can use like. There is a little bit more that goes into it you can use it for numerics. There's a lot of things that you can use this for but this is just the basics how you can use it today how you can get started on using the like. A nutshell that is how you use like and as I said before you can use like with numerical data as well but for demonstration purposes I wanted to use text data. Let's get rid of this really quick let's look at our entire table and I wanted to show you how to use null and not null. I can't really show you how to use null because I do not have any null fields I could easily update this table and make one null but that's in a future video where it's a little bit more advanced where you can start altering your data but just for purposes of showing you what null and not null is let's do where first name is null and if we see that's not going to return anything but if we say is not null it's going to return everything because nothing in here is null nothing in this first name column is null so that's how you use it there are a lot of use cases where you actually would use null and not null that will be in future videos probably in the project section or the portfolio section but we weren't able to show really how to use this super well but just as a demonstration that's really all it does it looks at the whole column and whether it is null or not null that's really all it's used for this is actually super useful and you can use it in a ton of situations but again for demonstration purposes that's really all it does so let's get rid of this let's look at in really quick so in is kind of like the equal statement but it's multiple equal statements so let's say we want to say we're first name equals gym and then we were like wait we also want to include Michael Scott so then we would have to write and where first name equals and then we would do Michael and then etc etc for anybody that we wanted to include but if we said in we could do an open parenthesis and then we can say gym we can say Michael and we can say as many people as we want going down the road just separating it by commas and if we had execute everything would be returned so it really is just a condensed way to say equal for multiple things so that is the where statement I think the where statement can get extremely complex but this really is highlighting the basics so if you can learn all of these concepts you will absolutely have the basics down and will be set to go over some more intermediate more advanced things with the where statement later on in the next video we're going to be going over the group by and the order by and then we are done with the sequel basics and then you can practice and work your way up into my intermediate level videos which are going to be coming out very shortly after these videos thank you guys so much for joining me if you like this tutorial series be sure to subscribe below and I'll see you in the next video