Aid sur une requete

yuri648 Messages postés 785 Statut Membre -  
yuri648 Messages postés 785 Statut Membre -
Bonjour,

je ne sai pas comment faire cette requete

-Find all the makers who have all their models of PC type in the PC table.

voila le model relationnel

Product(maker, model, type)

PC(code, model, speed, ram, hd, cd, price)

Laptop(code, model, speed, ram, hd, screen, price)

Printer(code, model, color, type, price)

et merci d'avence

10 réponses

snake-d12 Messages postés 258 Statut Membre 57
 
pouvez vous nous expliquer les relations entre ces tables
0
BadBoy3 Messages postés 128 Statut Membre 15
 
je pense que les relation sont claire!!!!!!! juste voir les proprité doublant dans chaque une des tables
0
redlifebig Messages postés 60 Statut Membre 23
 
select product.maker from product where maker not in (select product.maker from product where product.model not in (select pc.model from pc) and type="pc")
0
yuri648 Messages postés 785 Statut Membre 7
 
voila quelque explication:

The table "Product" includes information about the maker, model number, and type ('PC', 'Laptop', or 'Printer'). It is assumed that model numbers in the Product table are unique for all the makers and product types. Each PC uniquely specifying by a code in the table "PC" is characterized by model (foreign key referencing to Product table), speed (of the processor in MHz), total amount of RAM - ram (in Mb), hard disk drive capacity - hd (in Gb), CD ROM speed - cd (for example, '4x'), and the price. The table "Laptop" is similar to that one of PCs except for the CD ROM speed, which is replaced by the screen size - screen (in inches). For each printer in the table "Printer" it is told whether the printer is color or not (color attribute is 'y' for color printers; otherwise it is 'n'), printer type (laser, jet, or matrix), and the price.
0
yuri648 Messages postés 785 Statut Membre 7
 
la requete que vous m'avez donné Mr redlifebig elle me revois les maker qui 'ont au moin un pc dans la tables pc je l'ai essayé sur la console ;
merci
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
redlifebig Messages postés 60 Statut Membre 23
 
Bonjour

dans la requête que je t'ai donné
SR1:(select product.maker from product where product.model not in (select pc.model from pc) and type="pc")
nous renvoie tous les product maker qui on au moin un pc qui n'est pas dans la table pc après je fais
Select product.maker from product where maker not in SR1
donc les maker qui on tous les pc dans la table PC verifie de nouveau n'oublie pas NOT IN
0
yuri648 Messages postés 785 Statut Membre 7
 
vous pouvez essayer la requete ici

https://www.sql-ex.ru/exercises.php?N=11
merci
0
redlifebig Messages postés 60 Statut Membre 23
 
Bonjour

moi j'execute la requet sur une table mysql voici le schema
/*Table structure for table `pc` */

DROP TABLE IF EXISTS `pc`;

CREATE TABLE `pc` (
`code` varchar(50) default NULL,
`model` varchar(50) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Data for the table `pc` */

insert into `pc`(`code`,`model`) values ('1','a');

/*Table structure for table `product` */

DROP TABLE IF EXISTS `product`;

CREATE TABLE `product` (
`maker` varchar(20) default NULL,
`model` varchar(20) default NULL,
`type` varchar(20) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Data for the table `product` */

insert into `product`(`maker`,`model`,`type`) values ('g','a','PC'),('g','z','Laptop'),('g','b','PC'),('f','a','PC');

et voici la requete
Select distinct product.maker from product where maker not in (select product.maker from product where product.model not in (select pc.model from pc) and type='PC')

ça marche, maintenant que ça marche pas sur le site je ne sais pas pourquoi

Cordialement
0
yuri648 Messages postés 785 Statut Membre 7
 
meme je me suis douter du site qu'il marche pas bien
en tout cas j'ai compris le principe et merci bcp
0
redlifebig Messages postés 60 Statut Membre 23
 
dsl

j'ai trouvé l'erreur
Select distinct product.maker from product where maker not in (select product.maker from product where product.model not in (select pc.model from pc) and type='PC') and product.type='PC'

il falait ajouter le test ='PC' a la fin c tous
0
yuri648 Messages postés 785 Statut Membre 7
 
elle a marché 100% merci
0