Un précédent message ayant été déplacé sur le Forum Access, je reformule mon problème ici, car je pense qu'il s'agit réellement d'un problème SQL.

MES TABLES
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
CREATE TABLE Doc (
idDoc bigint NOT NULL ,
titreDoc nvarchar (50) NOT NULL ,
CONSTRAINT PK_Doc PRIMARY KEY (idDoc)
);
 
CREATE TABLE DocMot (
idDoc bigint NOT NULL ,
idMot bigint NOT NULL ,
CONSTRAINT PK_DocMot PRIMARY KEY (idDoc, idMot)
);
 
CREATE TABLE Mot (
idMot bigint NOT NULL ,
motCle nvarchar (50) NOT NULL ,
CONSTRAINT PK_Mot PRIMARY KEY (idMot)
);
MES VALEURS
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
INSERT INTO Doc (idDoc, titreDoc) VALUES (1, 'titre1');
INSERT INTO Doc (idDoc, titreDoc) VALUES (2, 'titre2');
INSERT INTO Doc (idDoc, titreDoc) VALUES (3, 'titre3');
 
INSERT INTO Mot (idMot, motCle) VALUES (1, 'mot1');
INSERT INTO Mot (idMot, motCle) VALUES (2, 'mot2');
INSERT INTO Mot (idMot, motCle) VALUES (3, 'mot3');
INSERT INTO Mot (idMot, motCle) VALUES (4, 'autre mot1');
 
INSERT INTO DocMot (idDoc, idMot) VALUES (1, 1);
INSERT INTO DocMot (idDoc, idMot) VALUES (1, 2);
INSERT INTO DocMot (idDoc, idMot) VALUES (1, 3);
 
INSERT INTO DocMot (idDoc, idMot) VALUES (2, 1);
INSERT INTO DocMot (idDoc, idMot) VALUES (2, 2);
INSERT INTO DocMot (idDoc, idMot) VALUES (2, 3);
INSERT INTO DocMot (idDoc, idMot) VALUES (2, 4);
 
INSERT INTO DocMot (idDoc, idMot) VALUES (3, 1);
INSERT INTO DocMot (idDoc, idMot) VALUES (3, 2);
INSERT INTO DocMot (idDoc, idMot) VALUES (3, 4);
MON PROBLEME
Comment obtenir tous les titreDoc en relation avec :
- un motCle contenant 'mot1'
- ET un motCle contenant 'mot2'
- ET un motCle contenant 'mot3'

RESULTAT ATTENDU (on notera l'absence de titre3)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
titreDoc
---------
titre1
titre2
MA REQUETE SQL (elle fonctionne)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
SELECT DISTINCT d.titreDoc
FROM Doc d
  INNER JOIN DocMot dm1 ON d.idDoc = dm1.idDoc
  INNER JOIN Mot m1 ON dm1.idMot = m1.idMot
 
  INNER JOIN DocMot dm2 ON d.idDoc = dm2.idDoc
  INNER JOIN Mot m2 ON dm2.idMot = m2.idMot
 
  INNER JOIN DocMot dm3 ON d.idDoc = dm3.idDoc
  INNER JOIN Mot m3 ON dm3.idMot = m3.idMot
 
WHERE (m1.motCle LIKE N'%mot1%')
  AND (m2.motCle LIKE N'%mot2%')
  AND (m3.motCle LIKE N'%mot3%')
MA QUESTION
Avec cette syntaxe, j'ai 2 INNER JOIN par motCle recherché, ce qui est coûteux.
J'ai des problèmes de performances avec cette syntaxe à partir de 3 mots sous ACCESS 2000.
Existe-t-il une syntaxe SQL moins coûteuse pour arriver au même résultat ?

Merci