Tuesday, July 28, 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
The author of this blog post is a technology fellow, an IT entrepreneur, and Educator in Kathmandu Nepal. With his keen interest in Data Science and Business Intelligence, he writes on random topics occasionally in the DataSagar blog.
RELATED ARTICLES

How to setup DNS Records in Cloudflare – Guide for Website Owners

Whether you're launching your first website, connecting a custom email address, or moving your domain to a new hosting provider, you've probably...

DeepSeek AI: The Open-Source AI Disruptor Shaking Up the Tech World

DeepSeek AI is revolutionizing the artificial intelligence landscape with its open-source, cost-effective, and highly customizable model. Built on cutting-edge transformer architecture and fine-tuned using reinforcement learning with human feedback (RLHF), DeepSeek delivers human-like text generation and accurate responses. Its efficient training techniques reduce computational costs by up to 40%, while its foundation on open-source frameworks like PyTorch and TensorFlow ensures seamless integration for developers. Whether you're a startup, a developer, or a large enterprise, DeepSeek offers unparalleled transparency, affordability, and performance, making it a game-changer in the world of AI. Discover why DeepSeek is outshining competitors like ChatGPT and Google Gemini in this comprehensive guide.

Useful Python Libraries for Data Science & ML Enthusiasts

Hi there, DataSagar here! If you're as passionate about data science as I am, then you know how overwhelming it can be...

Most Popular

How to setup DNS Records in Cloudflare – Guide for Website Owners

Whether you're launching your first website, connecting a custom email address, or moving your domain to a new hosting provider, you've probably...

DeepSeek AI: The Open-Source AI Disruptor Shaking Up the Tech World

DeepSeek AI is revolutionizing the artificial intelligence landscape with its open-source, cost-effective, and highly customizable model. Built on cutting-edge transformer architecture and fine-tuned using reinforcement learning with human feedback (RLHF), DeepSeek delivers human-like text generation and accurate responses. Its efficient training techniques reduce computational costs by up to 40%, while its foundation on open-source frameworks like PyTorch and TensorFlow ensures seamless integration for developers. Whether you're a startup, a developer, or a large enterprise, DeepSeek offers unparalleled transparency, affordability, and performance, making it a game-changer in the world of AI. Discover why DeepSeek is outshining competitors like ChatGPT and Google Gemini in this comprehensive guide.

Useful Python Libraries for Data Science & ML Enthusiasts

Hi there, DataSagar here! If you're as passionate about data science as I am, then you know how overwhelming it can be...

Nepal Government allowing IT Companies to Invest Abroad

In a landmark decision that signals Nepal’s intent to embrace globalization and technological advancement, the government has now allowed Nepali IT companies...

Recent Comments