Jointure de 3 tables sql

Résolu
jameskougar Messages postés 55 Date d'inscription   Statut Membre Dernière intervention   -  
jameskougar Messages postés 55 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,

J'essaie de faire une jointure de 3 tables et je bloque
j'ai 3 tables film, artiste et acteur et je voudrais la liste des films dans lequel ont joué ensemble deux acteurs mercier et hossein

j'ai fais ceci déjà
select idfilm from artiste, acteur where artiste.IDPERS = acteur.IDPERS and nom like 'MERCIER' 
intersect 
select idfilm from artiste, acteur where artiste.IDPERS = acteur.IDPERS and nom like 'HOSSEIN';
et ça me donne les idfilm des films dans lequel ils ont joué tous les deux,

et ce code là
select distinct titre from film, artiste where artiste.nom like 'MERCIER'
intersect
select distinct titre from film, artiste where artiste.nom like 'HOSSEIN';
me donne le titre des films qu'ils dans lesquels ils ont joué tous les deux.

Le problème c'est que je n'arrive pas lier ces deux codes pour trouver ensemble, alors comment je peux faire s'il vous plaît???
merci d'avance


A voir également:

2 réponses

hervé56 Messages postés 268 Date d'inscription   Statut Membre Dernière intervention   10
 
un truc comme ca surement....?

select * from (artiste ar left join acteur ac on ar.idpers=ac.idpers) left join film f on f.id_film=ar.id_film where ar.nom = 'mercier' group by f.titre
0
jameskougar Messages postés 55 Date d'inscription   Statut Membre Dernière intervention   2
 
merci pour ta réponse mais j'ai trouvé
select  titre, nom 
from film, artiste 
where film.idpers = artiste.IDPERS
and   film.idfilm in (select idfilm from artiste, acteur where artiste.IDPERS = acteur.IDPERS and nom like 'MERCIER' 
                      intersect 
                      select idfilm from artiste, acteur where artiste.IDPERS = acteur.IDPERS and nom like 'HOSSEIN');
0