An infographic explaining MySQL Join Types featuring: Visual diagrams of INNER, LEFT, RIGHT, and FULL JOINs with Venn-like representations Color-coded tables (Customers & Orders) showing matched/unmatched rows SQL syntax examples for each join type Use-case scenarios (e.g., 'Use LEFT JOIN to include all customers even without orders')

Mysql join types



SQL Join Types

INNER JOIN

An INNER JOIN returns records that have matching values in both tables.

Tables:

Customers  
ID Name
1 John
Orders  
OrderID CustomerID
1 1

SQL Query:

SELECT Customers.Name, Orders.OrderID FROM Customers INNER JOIN Orders ON Customers.ID = Orders.CustomerID;

LEFT JOIN

A LEFT JOIN returns all records from the left table, and the matched
records from the right table.

SELECT Customers.Name, Orders.OrderID FROM Customers LEFT JOIN Orders ON Customers.ID = Orders.CustomerID;

RIGHT JOIN

A RIGHT JOIN returns all records from the right table, and the matched
records from the left table.

SELECT Customers.Name, Orders.OrderID FROM Customers RIGHT JOIN Orders ON Customers.ID = Orders.CustomerID;

FULL JOIN

A FULL JOIN returns all records when there is a match in either the left
or right table records.

SELECT Customers.Name, Orders.OrderID FROM Customers FULL JOIN Orders ON Customers.ID = Orders.CustomerID;

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top