Codacoda
Back to Academy

relational database

SQL Joins

SQL joins combine rows from two or more tables based on a related column. INNER JOIN returns only matching rows, LEFT JOIN keeps all left-table rows, RIGHT JOIN keeps all right-table rows, and FULL JOIN keeps all rows from both tables. Joins are fundamental to querying normalized relational data.

Use Cases

  • Fetching customer details alongside their orders using INNER JOIN
  • Listing all employees including those with no department assignment using LEFT JOIN
  • Finding products that have never been ordered by comparing with an outer join

Visualization

BEFOREJOIN ONemployeesidnamedept_id1Alice102Bob203Carol99departmentsiddept_name10Engineering20Marketing30Sales
Speed:1x
Two tables: employees and departmentsStep 1 / 5

Implementation

Output

Click "Run Code" to see output...