Professional Documents
Culture Documents
--
-- Contenu de la table `post`
--
--
-- Structure de la table `category`
--
--
-- Contenu de la table `category`
--
SELECT *
FROM post AS p, category AS c
WHERE p.category_id = c.category_id;
Remarque:
les lignes où le champ « category_id » est à NULL ne sont pas apparues dans le résultat.
Les jointures complexes
SELECT *
FROM post AS p INNER JOIN category AS c
ON p.category_id = c.category_id;
SELECT *
FROM post AS p LEFT JOIN category AS c
ON p.category_id = c.category_id;
SELECT *
FROM post AS p RIGHT JOIN category AS c
ON p.category_id = c.category_id;
Outer Join (FULL JOIN) non suporté par MySql: utilizer UNION)
(
SELECT *
FROM post AS p LEFT JOIN category AS c
ON p.category_id = c.category_id
)
UNION
(
SELECT *
FROM post AS p RIGHT JOIN category AS c
ON p.category_id = c.category_id
);
SELECT post_title
FROM post JOIN category
USING (category_id)