From the course: MySQL Data Analysis

Unlock this course with a free trial

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

RIGHT JOIN

RIGHT JOIN

- [Instructor] All right, we're going to briefly touch on RIGHT JOIN. RIGHT JOIN returns all records from the RIGHT table, the second table that you specify, and any matched records from the LEFT table. RIGHT JOIN has a very similar syntax to LEFT JOIN and INNER join, just replace INNER and LEFT with RIGHT. Here's where you tell SQL that you want to return everything in the overlap, as well as everything in the RIGHT table, but exclude anything from the LEFT table if there isn't a match. And here's where you'll prescribe your RIGHT table and tell the server how you want it to attempt to match. For example, if you're selecting from rental, you may want to RIGHT JOIN to customer on rental.customer_id=customer.customer_id. In this case, you're going to get all the data from customer, and you're only going to get data from rental if there's a match. This part's really important. You can think of RIGHT JOIN just like the opposite of LEFT JOIN. Instead of keeping all records from your…

Contents