From the course: MySQL for Non-Programmers

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Joins

Joins

- [Instructor] We discussed clauses previously, and now I'll introduce the JOIN clause, which is used when you need to combine data from two or more tables. MySQL supports four types of joins. Inner join, where only the records that have matching values in both tables are returned. For example, we can do SELECT Orders.OrderID, Customer.FirstName, and then Orders.Status FROM Orders, and now comes the inner join part, INNER JOIN on Customer, and we want to give it the actual column that we want the join to match up on. So it'll be ON Orders.CustomerID, and it must equal the Customer.CustomerID. This way we know which column in the Customer table we are referring to, because the Orders.CustomerID will have that customer ID number that we're looking for. And as you can see, we prefix each column with the table we want the value to come from. We do this because tables can have overlapping column names. And if we…

Contents