Answer: Combining JOIN Statements

Find a detailed explanation of how to combine multiple joins on tables.

Solution

The solution is given below:

Press + to interact
/* The query to apply Mulitple JOINs */
SELECT e.EmpName, p.ProjectName, s.SkillName
FROM Employees AS e
INNER JOIN Projects AS p ON e.EmpID = p.EmpID
INNER JOIN Skills AS s ON p.SkillID = s.SkillID;

Explanation

The explanation of the code solution is given below:

  • Line 2: The SELECT query selects EmpName, ProjectName, and SkillName. The e.EmpName refers to the EmpName column from the Employees table (aliased as e), the p.ProjectName refers to the ProjectName column from the Projects table (aliased as p), and the s.SkillName refers to the SkillName column from the Skills table (aliased as s).

  • Line 3: The data is retrieved from the Employees table.

  • Line 4: The INNER JOIN is applied to the Projects table on the EmpID columns in ...

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.