Search⌘ K
AI Features

Answer: Using LEFT JOIN

Explore how to apply the LEFT JOIN operation in SQL to combine data from employees and projects tables. Understand the use of aliases, selecting specific columns, and alternate join techniques like USING and RIGHT JOIN to handle related interview questions effectively.

Solution

The solution is given below:

MySQL
/* The query to apply LEFT JOIN */
SELECT e.EmpName, p.ProjectName
FROM Employees AS e
LEFT JOIN Projects AS p ON e.EmpID = p.EmpID;

Explanation

The explanation of the solution code is given below:

  • Line 2: The SELECT query selects EmpName and ProjectName from Employees and Projects, respectively. We use AS to set an alias for the tables.

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