Jointure de 3 tables sql

Résolu/Fermé
jameskougar Messages postés 55 Date d'inscription jeudi 28 août 2008 Statut Membre Dernière intervention 18 mars 2013 - 25 août 2011 à 09:31
jameskougar Messages postés 55 Date d'inscription jeudi 28 août 2008 Statut Membre Dernière intervention 18 mars 2013 - 25 août 2011 à 11:41
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 269 Date d'inscription lundi 15 novembre 2010 Statut Membre Dernière intervention 25 mars 2017 10
Modifié par hervé56 le 25/08/2011 à 10:49
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 jeudi 28 août 2008 Statut Membre Dernière intervention 18 mars 2013 2
25 août 2011 à 11:41
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