📁 INNER, LEFT, RIGHT & FULL OUTER Explained

🔗 Lab 2.3: SQL JOINS — INNER, LEFT, RIGHT, FULL OUTER

This lab introduces SQL JOINs using real-world Bangladeshi data. JOINs allow you to combine data from two or more tables based on a related column — typically a foreign key. Let's practice with Employees and Departments tables.

📁 Employees Table

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

📁 Departments Table

dept_id dept_name
10IT
20HR
40Marketing

đŸ§Ē 1. INNER JOIN

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

Returns only employees who belong to a department (matched rows in both tables).

đŸ§Ē 2. LEFT JOIN

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

Returns all employees — even if they don’t belong to any department (e.g., Imran).

đŸ§Ē 3. RIGHT JOIN

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

Returns all departments — even if no employee belongs to them (e.g., Marketing).

đŸ§Ē 4. FULL OUTER JOIN

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

Returns all records from both tables. If there’s no match, it fills with NULL.

✅ Use JOINs when your data is spread across multiple tables and you want a combined result based on a relationship.
SQL JOIN tutorial, INNER JOIN example, LEFT JOIN SQL, RIGHT JOIN explanation, FULL OUTER JOIN SQL, JOIN with Bangladeshi data, SQL multi-table query, SQL employee and department JOIN, SQL JOINs for beginners

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

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