MySQL Join
Learn all about MySQL Join in this comprehensive tutorial.
- •You can combine rows from two or more tables, based on a related column between them, by using a JOIN statement.
- •In the example above, Hannah, and Michael were excluded from the result, that is because INNER JOIN only shows the records where there is a match.
- •If you want to return all products, and the users who have them as their favorite, even if no user have them as their favorite, use the RIGHT JOIN statement:
Join Two or More Tables
You can combine rows from two or more tables, based on a related column between them, by using a JOIN statement.
Consider you have a "users" table and a "products" table:
users
products
These two tables can be combined by using users' fav field and products' id field.
LEFT JOIN
In the example above, Hannah, and Michael were excluded from the result, that is because INNER JOIN only shows the records where there is a match.
If you want to show all users, even if they do not have a favorite product, use the LEFT JOIN statement:
RIGHT JOIN
If you want to return all products, and the users who have them as their favorite, even if no user have them as their favorite, use the RIGHT JOIN statement:
Module quiz
2 questionsWhich of the following is true about MySQL Join?
What is the most common pitfall when working with MySQL Join?
Answer all questions to submit.