Requête sur deux tables de plusieurs à plusieurs
Bonjours à tous
Je suis actuellement en difficulté sur une requête qui doit afficher le nom de tous les logiciels présents sur un poste.
En sachant qu'il y a une table logiciel une table computer et une table entre les deux pour faire la liaison.
Il faut savoir que un logiciel peut être présent sur plusieurs poste et un poste peut avoir plusieurs logiciel.
J'ai donc crée mes tables de cette façon :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| CREATE TABLE software (
idSoft int(4) NOT NULL AUTO_INCREMENT,
nom varchar(255) NOT NULL,
version varchar(255) NOT NULL,
nombre int(10) NOT NULL,
softCat varchar(4) NOT NULL,
chaineDelete varchar(255) NOT NULL,
argBefore varchar(255) NOT NULL,
argAfter varchar(255) NOT NULL,
PRIMARY KEY (idSoft)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE computer (
idComputer int(4) NOT NULL AUTO_INCREMENT,
nom varchar(255) NOT NULL,
analyse varchar(255) NOT NULL,
ip varchar(20) NOT NULL,
os varchar(20) NOT NULL,
PRIMARY KEY (idComputer)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE softInComputer (
idComputer int(4) NOT NULL,
idSoft int(4) NOT NULL,
CONSTRAINT fkSoft FOREIGN KEY (idSoft) REFERENCES software(idSoft),
CONSTRAINT fkComputerSoft FOREIGN KEY (idComputer) REFERENCES computer(idComputer)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
Mais lorsque j’exécute cette requête :
Code:
1 2 3
| SELECT software.nom, computer.nom
FROM computer, software, softInComputer
WHERE softInComputer.idComputer = 1 |
il m'affiche tous les pc avec tous les logiciels... :(
Si vous avez un peu d'aide à m'accorder...
Merci à vous