Database IntegrationLesson 58Free preview
MySQL Join
This lesson is part of Node.js · All levels
Summary
This lesson shows how to combine multiple tables with JOIN in a MySQL query from Node.js. With JOIN, the customer data and their orders can be read in a single query and then processed as an array of objects. You'll understand INNER JOIN and LEFT JOIN and use the column alias to make the results easy to read.
Key points
- INNER JOIN returns only the matching rows on both tables.
- LEFT JOIN maintains all the rows of the left table even though there are no pairs in the right table.
- Use the table aliases (e.g. c and o) and the US for the result column to be neat.
- Enter the foreign key column as the ON condition for the correct join result.
- The result of a large join should be limited to WHERE/LIMIT and processed gradually.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.