Learn SQL
JOINS - INNER JOIN
36.3
Lesson

INNER JOIN - Continued

Let’s notice a few more points in the basic JOIN query.

Notice, that the no. of students is 25, but the no. of records in the result of JOIN query are only 22. This is because

  • 2 students (with id 15 and 31) do not have a courseId data.

  • 1 student (with id 24) has a courseId (20) which does not match any id in the courses table.

Observe that these students are not included in the final result of the JOIN query.

This behaviour of the basic JOIN, i.e including strictly those rows from both tables which match the criteria specified in the ON clause, is called INNER JOIN. To assert the same, we can replace JOIN in the above query with INNER JOIN, and observe that the results still remain the same.