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.SkillNameFROM Employees AS eINNER JOIN Projects AS p ON e.EmpID = p.EmpIDINNER JOIN Skills AS s ON p.SkillID = s.SkillID;
Explanation
The explanation of the code solution is given below:
Line 2: The
SELECT
query selectsEmpName
,ProjectName
, andSkillName
. Thee.EmpName
refers to theEmpName
column from theEmployees
table (aliased ase
), thep.ProjectName
refers to theProjectName
column from theProjects
table (aliased asp
), and thes.SkillName
refers to theSkillName
column from theSkills
table (aliased ass
).Line 3: The data is retrieved from the
Employees
table.Line 4: The
INNER JOIN
is applied to theProjects
table on theEmpID
columns in ...
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.