Welcome. In our last video, we talked about qualifying your table names and so we've touched on this briefly. But I just want to go into it a little bit more detail in regards to using table aliases. We've used aliases when we are aggregating the field, so if we're taking the average selling price we'll oftentimes create an alias for that so we know what to call the name. We can do a similar thing when we're using tables and joining tables together. And why we do this is because it makes it a lot easier to read and write. If we are joining two tables together and we need to state where each individual column is from before we state that column, it can be a lot to write out an alias as some of the table names may be quite long. So in this video, we're going to show you how to create aliases for use in our queries, discuss some common naming conventions when using aliases, and discuss and establish self-joins within a SQL database. So an alias is helpful because it can help you by just shortening names and simplifying how we're pre-qualifying them. Then something nice about the alias is it's not rewriting the name of the table or rewriting anything. It's just only stored for that duration of the query. So an example of this is in the query example. We have some information we're pulling from vendors and products. And so before every item that we're pulling, we're listing out its vendor name, where it's coming from, and the product name, product price. We're listing the name of the table before pulling that column name. Then we also have the same thing on our join. We're seeing where are the vendors for vendor_id goes and the products for the vendor_id. We start to use the aliases. What happens is it simplifies what we're writing quite a bit. So instead of having vendor name, all we have is v and then the name. Or instead of having product and then the name, all we have is p and then the name. Same thing with price, instead of having product price, we just have p price. To qualify this, or create the alias, we do this when we're saying when we're getting the table. When we're getting it from Vendors, we're going to say Vendors is going to be v and then Products is p. Again, you can make these aliases as anything you want. Like I said earlier in the course, some people like to do a, b, c, d. But I like to keep it in a logical fashion. Some people also like to abbreviate the names a little bit. So instead of maybe using v, it'd be ven for Vendor or prod for Products. It's really up to you. This is what I found helpful so you're welcome to use that but do what suits you. Then you can see in our WHERE clause, it also simplifies that as well. So instead of fully writing out vendor or product id, we just use the v and the p again. Again, just a really helpful little tip you can do, you can always write it as a v or just do vendor as v. And that will also help when pre-qualifying in most dat base management systems. Okay, so back to joins. We can actually join a table to itself. And perhaps, not surprisingly, these are called self joins. In this instance, what we're going to do is we're going to match customers that are from the same city. We have all of our customers listed out in the table and where they're from. But we want to match these, so we're going to take the table and almost treat them as two separate tables and join the original table to itself. To do this, what it's going to have to take is you'll have your select statement, you'll have your column names. And then what you're going to do is when you list where it's coming from, you're going to qualify table name 1 as table name 1 and then table name 2 as table name 2. So if we look at this in our example, we have select our company name and that's going to be company one. We're qualifying that. Then we're going to select company name again as company name two and we're going to select the city that we want this from. To get these tables, we are listing out the same table customers two times, but you can see we're qualifying it in two different ways. So first, it's customers as A, and then the second time, it's customers as B. To do this then, and to join on itself, we're going to say where A.CustomerID equals B.CustomerID and city, A.City equals B.City. And then just to make it easier to read, we will order by A.City. So this is a great example why table aliases are so important, especially when you're joining a table to itself. You have to have a table alias. There's no other way this could happen. But also they really help you to stay clear on what's coming from what. So this is a really helpful method when you want to match certain elements that are in the same table and it is a great tool to have in your toolbox for SQL. Okay, that does it for this lesson so buckle up because we have some more joins coming at you in our next video.