Answer: Using INNER JOIN
Find a detailed explanation of how to apply INNER JOIN on tables.
We'll cover the following...
We'll cover the following...
Solution
The solution is given below:
MySQL
/* The query to apply INNER JOIN */SELECT e.EmpName, p.ProjectNameFROM Employees AS eINNER JOIN Projects AS p ON e.EmpID = p.EmpID;
Explanation
The explanation of the solution code is given below:
Line 2: The
SELECTquery selectsEmpNameandProjectName. Thee.EmpNamerefers to theEmpNamecolumn from theEmployeestable (aliased ase), andp.ProjectNamerefers to theProjectNamecolumn from theProjectstable (aliased asp).Line 3: The data is retrieved from the
Employeestable.Line 4: The
INNER JOINis applied withEmployeesandProjectson theEmpIDcolumn in both the tables.
Recall of relevant concepts
We have covered the following concepts in this question: