softwaretips4u Tips that Transform
← Back to Homepage ← Back to Articles

INNER JOIN vs LEFT JOIN in SQL

SQL JOINs allow you to retrieve related data from multiple tables. Here’s a clear comparison between INNER JOIN and LEFT JOIN with examples.

πŸ”Ή INNER JOIN

SELECT e.name, d.department_name
FROM employees e
INNER JOIN departments d
   ON e.dept_id = d.id;

πŸ‘‰ Shows employees only if they belong to a department.

πŸ”Ή LEFT JOIN

SELECT e.name, d.department_name
FROM employees e
LEFT JOIN departments d
   ON e.dept_id = d.id;

πŸ‘‰ Shows all employees, even those without a department.

← Back to Articles | 🏠 Back to Homepage