Languages
[Edit]
EN

MySQL - JOIN query cases with examples

13 points
Created by:
Waleed-Gates
322

In this short article, we would like to show how to built MySQL JOIN queries for cases.

Possible JOIN cases in MySQL.
Possible JOIN cases in MySQL.
VisualisationSQL Query

INNER JOIN in MySQL

INNER JOIN

SELECT *
FROM table_a A
JOIN table_b B ON A.key = B.key

LEFT OUTER JOIN in MySQL

LEFT OUTER JOIN

SELECT *
FROM table_a A
LEFT JOIN table_b B ON A.key = B.key

RIGHT OUTER JOIN in MySQL

RIGHT OUTER JOIN

SELECT *       
FROM table_a A
RIGHT JOIN table_b B ON A.key = B.key

FULL OUTER JOIN in MySQL

FULL OUTER JOIN

SELECT * FROM table_a A
LEFT JOIN table_b B ON A.key = B.key
UNION
SELECT * FROM table_a A
RIGHT JOIN table_b B ON A.key = B.key

LEFT OUTER JOIN with exclusion in MySQL

LEFT OUTER JOIN with exclusion

SELECT  *
FROM table_a A
LEFT JOIN table_b B ON A.key = B.key
WHERE B.key IS NULL

RIGHT OUTER JOIN with exclusion in MySQL

RIGHT OUTER JOIN with exclusion

SELECT *
FROM table_a A
RIGHT JOIN table_b B ON A.key = B.key
WHERE A.key IS NULL

FULL OUTER JOIN with exclusion in MySQL

FULL OUTER JOIN with exclusion

SELECT * FROM table_a A
LEFT JOIN table_b B ON A.key = B.key
WHERE B.key IS NULL 
UNION
SELECT * FROM table_a A
RIGHT JOIN table_b B ON A.key = B.key
WHERE A.key IS NULL

MySQL

Native Advertising
ūüöÄ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

‚̧ԳŹūüíĽ ūüôā

Join