-
SQL question
Hey everybody,
I am new to sql and have a problem to find the solution for this exercise: Find out the makers that sale PCs but not laptops.
The database scheme consists of four relations:
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)
My own query:
select distinct maker from product, pc
where product.model = pc.model
and type in('pc','printer')
The problem is that i also get the makers who sells pc and laptops.
Thnx for any help,
-
This assumes that model is unique across makers and pc and laptop do not share a model name (may be true)
select maker
from product, pc
where product.model = pc.model
and model not in (select model from laptop)
-
SELECT maker from product p,pc c where p.model=c.model
AND type not in('laptop')
-
the answer is:
SELECT * FROM product WHERE not exists (select * from laptop where
product.MODEL=laptop.model) and MAKER not in (SELECT MAKER FROM
product WHERE model in (SELECT model FROM laptop)) and maker in
(SELECT MAKER FROM product WHERE model in (SELECT MODEL FROM pc))
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|