<aside> 💡

Project Overview:

This project generates a report that associates each employee's name with their unique ID if available. For employees without a unique ID, the result will display NULL. The solution demonstrates the use of SQL LEFT JOIN for combining data from multiple tables while retaining unmatched records.

</aside>


Problem Description:

Tables:

  1. Employees:
  2. EmployeeUNI:

The task is to generate a table showing:


Solution:

The query uses a LEFT JOIN to combine Employees with EmployeeUNI, ensuring all employees are included, even if they do not have a unique ID.

SELECT
    EmployeeUNI.unique_id,
    Employees.name
FROM
    Employees
LEFT JOIN
    EmployeeUNI
ON
    Employees.id = EmployeeUNI.id;


Explanation:

  1. Joining Tables:
  2. Selecting Columns:

Example Input and Output:

Input: