I am trying to find the makers of products who only make laptops and not PC's
Relations:
Product(maker, model, type)
Laptop(Model, price, speed, ram, hd, screen)
PC(model, price, speed, ram, hd)
Printer(model,price, color, price)
What I have tried
(SELECT maker, type
FROM product WHERE type = 'laptop')
DIFFERENCE
(SELECT maker, type
FROM product WHERE type = 'pc');
I take it there is no difference operation in MySQL?
select maker, type from product
where type='laptop' and
maker not in (select maker from product where type = 'pc')
SELECT
p1.maker,
p1.type
FROM
product p1
LEFT JOIN product p2 ON p2.maker = p1.maker AND p2.type = 'pc'
WHERE
p1.type = 'laptop'
p2.maker IS NULL
SELECT maker, type FROM product WHERE type = 'laptop' AND type != 'pc';
SELECT `maker`, `type` FROM `product` WHERE `type` = 'laptop' AND `maker` NOT IN
(SELECT `maker`, `type` FROM `product` WHERE `type` = 'pc');
SELECT p.maker, p.type
FROM product p
WHERE p.type = 'laptop'
AND NOT EXISTS (
SELECT p2.maker, p2.type
FROM table p2
WHERE p2.type = 'pc'
AND p2.maker = p1.maker
)