Toutes Jointures SQL sous MySQL

Intro

Les jointures sont faites pour mettre en relation deux (ou plus) tables pour récupérer des informations de ces tables.

En fonction de la clause JOIN saisie, le résultat obtenu est différent. La section suivante présente l’ensemble des Jointures possibles entre deux tables.

Toutes les jointures possibles entre 2 tables

schéma jointure requête sql
SELECT A.`col1`, B.`col1`
FROM TableA AS A
LEFT JOIN TableB AS B
ON A.`ID` = B.`ID`
SELECT A.`col1`, B.`col1`
FROM TableA AS A
RIGHT JOIN TableB AS B
ON A.`ID` = B.`ID`
SELECT A.`col1`, B.`col1`
FROM TableA AS A
LEFT JOIN TableB AS B
ON A.ID = B.ID
WHERE B.`ID` IS NULL
SELECT A.`col1`, B.`col1`
FROM TableA AS A
RIGHT JOIN TableB AS B
ON A.`ID` = B.`ID`
WHERE A.`ID` IS NULL
SELECT A.`col1`, B.`col1`
FROM TableA AS A
FULL OUTER JOIN TableB AS B
ON A.`ID` = B.`ID`
SELECT A.`col1`, B.`col1`
FROM TableA AS A
FULL OUTER JOIN TableB AS B
ON A.`ID` = B.`ID`
WHERE A.`ID` IS NULL OR B.`ID` IS NULL
SELECT A.`col1`, B.`col1`
FROM TableA AS A
INNER JOIN TableB AS B
ON A.`ID` = B.`ID`