🔗 Combine Employee and Department Data Using SQL JOIN

🔗 Combine Employee and Department Data Using SQL JOIN

To show complete information about employees and their departments, we can combine data from two tables using SQL JOIN. We'll demonstrate this using a Bangladeshi employee dataset.

📁 Employees Table

emp_id emp_name dept_id
1Rakib Hossain10
2Sharmin Akter20
3Imran KabirNULL

📁 Departments Table

dept_id dept_name
10IT
20HR
30Marketing

đŸ§Ē INNER JOIN: Match Only Existing Departments

SELECT e.emp_name, d.dept_name
FROM employees e
INNER JOIN departments d
ON e.dept_id = d.dept_id;

This query returns only employees who have a valid department assigned.

🧾 Result:

  • Rakib Hossain — IT
  • Sharmin Akter — HR

đŸ§Ē LEFT JOIN: Show All Employees, Even Without Department

SELECT e.emp_name, d.dept_name
FROM employees e
LEFT JOIN departments d
ON e.dept_id = d.dept_id;

Returns all employees. If a department is missing (NULL), it still shows the employee with blank dept_name.

🧾 Result:

  • Rakib Hossain — IT
  • Sharmin Akter — HR
  • Imran Kabir — (no department)

📌 Summary

  • INNER JOIN – Combines data only where matching dept_id exists in both tables
  • LEFT JOIN – Shows all employees, including those without a department
✅ Use JOINs to bring together data from multiple tables and create meaningful reports or dashboards.
SQL JOIN example, combine employee department SQL, INNER JOIN vs LEFT JOIN, Bangladeshi SQL dataset, SQL practical joins, SQL for beginners Bangladesh, SQL combine tables, employee department report SQL

āĻ•োāύ āĻŽāύ্āϤāĻŦ্āϝ āύেāχ:

āĻāĻ•āϟি āĻŽāύ্āϤāĻŦ্āϝ āĻĒোāϏ্āϟ āĻ•āϰুāύ