Sunday, August 23, 2026
Home Academic Joins in SQL

Joins in SQL

With SQL, there are various JOIN types that let you combine data from different tables. Below is a quick summary of the most popular JOIN kinds and their syntax:

INNER JOIN: An INNER JOIN returns only the rows that match the join condition in both tables.
Syntax:

SELECT *
FROM table1
INNER JOIN table2
ON table1.column = table2.column;

Example:

SELECT employees.id, employees.name, department.name
FROM employees
INNER JOIN departments
ON employees.department_id = departments.id;

LEFT JOIN (or LEFT OUTER JOIN): A LEFT JOIN returns all rows from the left table (table1), even if there is no match in the right table (table2).
Syntax:

SELECT *
FROM table1
LEFT JOIN table2
ON table1.column = table2.column;

Example:

SELECT employees.id, employees.name, department.name
FROM employees
LEFT JOIN departments
ON employees.department_id = departments.id;

RIGHT JOIN (or RIGHT OUTER JOIN): A RIGHT JOIN returns all rows from the right table (table2), even if there is no match in the left table (table1).
Syntax:

SELECT *
FROM table1
RIGHT JOIN table2
ON table1.column = table2.column;

Example:

SELECT employees.id, employees.name, department.name
FROM employees
RIGHT JOIN departments
ON employees.department_id = departments.id;

FULL JOIN (or FULL OUTER JOIN): A FULL JOIN returns all rows from both tables, even if there is no match in either table.
Syntax:

SELECT *
FROM table1
FULL JOIN table2
ON table1.column = table2.column;

Example:

SELECT employees.id, employees.name, department.name
FROM employees
FULL JOIN departments
ON employees.department_id = departments.id;

Data from different tables can be combined using JOINs if they share a column or collection of columns. They are a crucial component of SQL and are commonly used in reporting and data analysis.

datasagarhttp://www.DataSagar.com
Sagar is multidisciplinary technologist, educator, and entrepreneur based in Nepal. As the founder of Illionso Technologies and Kashi Garden Resort, he operates at the intersection of web architecture, data intelligence, innovation, and digital transformation. From building digital solutions to scaling real-world concepts, his mission is to share knowledge alongside merge emerging as well as disruptive technologies with transformative offline experiences.
RELATED ARTICLES

SynthID and C2PA Explained

Welcome to another AI-focused article here on datasagar.com! As I scroll through my social media feeds lately, I find myself playing a...

Why Linux Won the Infrastructure War? Lessons from Linus Torvalds

In 1991, 21-year-old Linus Torvalds announced a "hobby" operating system. Today, Linux powers supercomputers, cloud servers, and Android. Explore his journey, the open-source economy, and the lessons for modern developers.

What Is Vibe Coding? A Complete Beginner’s Guide to Building Software and Web Pages With AI

A few years ago, building a website meant sitting down with a programming book, picking a language, and slowly working through syntax...

Most Popular

SynthID and C2PA Explained

Welcome to another AI-focused article here on datasagar.com! As I scroll through my social media feeds lately, I find myself playing a...

Why Linux Won the Infrastructure War? Lessons from Linus Torvalds

In 1991, 21-year-old Linus Torvalds announced a "hobby" operating system. Today, Linux powers supercomputers, cloud servers, and Android. Explore his journey, the open-source economy, and the lessons for modern developers.

What Is Vibe Coding? A Complete Beginner’s Guide to Building Software and Web Pages With AI

A few years ago, building a website meant sitting down with a programming book, picking a language, and slowly working through syntax...

What is Answer Engine Optimization (AEO)? Getting Ready for AI Powered Search and Agentic Era Digital Marketing

Search is changing faster than it has in the last two decades. For years, businesses focused on ranking their websites on search...