Jointure de données dans SQL
Maham Faisal Khan
Senior Content Developer, DataCamp

SELECT *
FROM left_table
INNER JOIN right_table
ON left_table.id = right_table.id;

Une semi-jointure sélectionne les enregistrements de la première table lorsqu’une condition est remplie dans la deuxième table.



SELECT country, continent, president
FROM presidents;
| country | continent | president |
| -------- | ------------- | ----------------------- |
| Egypt | Africa | Abdel Fattah el-Sisi |
| Portugal | Europe | Marcelo Rebelo de Sousa |
| USA | North America | Joe Biden |
| Uruguay | South America | Luis Lacalle Pou |
| Pakistan | Asia | Asif Ali Zardari |
| Chile | South America | Gabriel Boric |
| India | Asia | Droupadi Murmu |
SELECT country
FROM states
WHERE indep_year < 1800;
|----------|
| country |
|----------|
| Portugal |
| Spain |
|----------|
SELECT president, country, continent
FROM presidents
WHERE country IN
(SELECT country
FROM states
WHERE indep_year < 1800);
|-------------------------|-----------|-------------|
| president | country | continent |
|-------------------------|-----------|-------------|
| Marcelo Rebelo de Sousa | Portugal | Europe |
|-------------------------|-----------|-------------|


SELECT country, president
FROM presidents
WHERE continent LIKE '%America'
AND country NOT IN
(SELECT country
FROM states
WHERE indep_year < 1800);
| country | president |
| -------- | ---------------- |
| Uruguay | Luis Lacalle Pou |
| Chile | Gabriel Boric |
Jointure de données dans SQL