 Hey everybody, this is Brian. Welcome to the 50th lamp tutorial. Today we're going to be discussing how to select records. Now, we've got our table and from our previous tutorials, you can see how we've got a primary key, a description cost, date added, and we've got some information down here. We can actually go in and select some rows here and execute this. You can see how we've just got, you know, three rows in here. Now, notice how this is a little bit different than our last tutorial. There's no single quotes around this. The single quotes are optional when you're actually doing this. Select star from database, tables, and we want to actually define what we want to find. So we're going to say where and then in parentheses. The where statement says we're going to look for something specific. Now we need to give it something to specifically look for. We're going to say ID tbl underscore products. Wow, I cannot spell. It's up with my keyboard tonight. And we're going to say where the primary key equals one and we're just going to execute this. Now you see how even though we've got three rows in here, it only returned the first one. You could even say greater than one. And it'll return everything. That's not one. So that's how you would actually go about filtering data. You could say you know, pretty much anything you wanted to do within the where. For example, let's just say, let's actually go back here a little quick. I want to do a quick demo. All right, we've got name here, name here, Bob's gun shop. So let's actually insert a little more information here. We'll say Chad's gun shop and let's add another one. Mark's gun shop. So now we've got some data in there. Let's actually refresh this. So going back with our example, you could say where and you're just returning the description where it is name here. But what if you want to find something that's like, for example, you want to find gun? So we'll say like. Now we get to add in some wildcards here. We use the percent sign for gun and then percent sign after it. So pretty much anything that includes the word gun did not like that. There we go. So anything that includes the word gun because our percent means anything before and anything after. So we have Bob's guns, Chad's guns, Mark's guns. Pretty neat, huh? So always remember that when you're doing a select statement, the where will allow you to filter things and the syntax is where column operator value. Very simple to understand. And let's actually grab another one and we'll say where, let's see here. We'll say we want where it's greater than where it's greater than three and we're just going to grab this up here. So that's a pretty hefty select statement here. Let's actually execute this. Let's get rid of that previous one. Sorry about that. Sorry to display, but I just want to clean things up a little bit here. So what we're saying here is select star or anything from database, table name, where column is greater than three and column is like description. Pretty simple to understand, but I'm going to walk you through it. We're selecting star, which means we're selecting any column from the database from the table, where this column, the ID, TBL products is greater than three. See how we have four and five? And, meaning we have an and here, the description is like and then we have our little code here, gun. That's how you can actually get a little more granular. You can also say things like or and get different results. We're saying we want anything where the primary key is greater than three or it contains the description gun. That's how this little guy right here, Bob's gun shop got in there because it contains the description gun. Now, what if you want to filter this down even further? You don't want all these columns. Well instead of star, you would just add column names and then you just tell it what columns you want. Separated by comma, of course. So you have description, select description and cost. Notice the comma from database tables, where and then you've got your where statement. Now if you wanted to simplify this even further, if you get sick of typing that database, you can say use my store and that'll tell my SQL to use that specific database. Sometimes it doesn't like it. Sometimes it does. It just really depends. In my example, it did not like it, but I think it's because I forgot that. There we go. Tada! There it goes. I forgot the semicolon first time. And that's another important note. Always remember the semicolon at the end of your statements. Sometimes you won't see them in examples, but you should always put them in there just for practice. Now that's pretty much it with the select statement. Um, there's a lot more to actually using the select statement rather than just displaying data, but its most common use is by far selecting data, filtering it using where to actually show things on the screen. And when we get back to PHP land, I'll show you how to actually take the data from this select statement and put it up on the screen in a manner that PHP can use it. That's all for this tutorial. I hope you found this educational and entertaining and thank you for watching.