« MySQL/Requêtes » : différence entre les versions

Contenu supprimé Contenu ajouté
Ligne 333 :
</table>
 
=== CROSSINNER JOIN ===
<source lang=sql>
SELECT hindi.Tag, english.Inenglish, hindi.Inhindi
FROM english, hindi
WHERE english.Tag = hindi.Tag
-- égal
SELECT hindi.Tag, english.Inenglish, hindi.Inhindi
FROM english INNER JOIN hindi ON english.Tag = hindi.Tag
</source>
 
<table>
<tr><td>Tag </td> <td>Inenglish</td> <td>Inhindi </td></tr>
<tr> <td> 2 </td> <td> Two </td> <td> Do </td> </tr>
<tr> <td> 3 </td> <td> Three </td> <td> Teen </td> </tr>
</table>
 
{{remarque|Le comportement d'un <code>JOIN</code> seul est <code>INNER JOIN</code>, qui est aussi synonyme de <code>CROSS JOIN<ref>https://dev.mysql.com/doc/refman/5.7/en/join.html</ref>.}}
 
La jointure cartésienne décrit le cas où chaque ligne d'une table est jointe à toutes celles d'une autre.
<source lang=sql>
Ligne 354 ⟶ 371 :
</table>
 
=== INNERNATURAL JOIN ===
La {{wt|jointure naturelle}} équivaut à <code>INNER JOIN</code> sur toutes les colonnes communes des deux tables.
<source lang=sql>
SELECT hindi.Tag, english.Inenglish, hindi.Inhindi
FROM english, hindi
WHERE english.Tag = hindi.Tag
-- égal
SELECT hindi.Tag, english.Inenglish, hindi.Inhindi
FROM english INNER JOIN hindi ON english.Tag = hindi.Tag
</source>
 
=== USING ===
<table>
Le mot <code>USING</code> est compatible MySQL 4, mais change avec MySQL 5. La requête suivante est équivalente à celles <code>INNER JOIN</code> ci-dessus :
<tr><td>Tag </td> <td>Inenglish</td> <td>Inhindi </td></tr>
<tr> <td> 2 </td> <td> Two </td> <td> Do </td> </tr>
<tr> <td> 3 </td> <td> Three </td> <td> Teen </td> </tr>
</table>
 
Le mot <code>USING</code> est compatible MySQL 4, mais change avec MySQL 5. La requête suivante est équivalente à celles ci-dessus :
<source lang=sql>
SELECT hindi.tag, hindi.Inhindi, english.Inenglish
Ligne 376 ⟶ 381 :
USING (Tag)
</source>
 
{{remarque|Le comportement d'un <code>JOIN</code> seul est <code>INNER JOIN</code>.}}
 
=== OUTER JOIN ===