Reputation: 1
I have a table called "Product".There are three columns in that table.Maker,Model and Type. Model is the primary that is used to link with other tables.The content in the table is like this
MODEL MAKER TYPE
1 A Laptop
2 A PC
3 B Laptop
4 C Laptop
5 B Printer
6 D Printer
7 B PC
8 D Printer
9 C PC
10 A Printer
I want only those makers who make all the three products.How to obtain the result?Please help Me.
Upvotes: 0
Views: 119
Reputation: 143966
How about:
SELECT DISTINCT(MAKER) FROM Product
WHERE MAKER IN (SELECT MAKER FROM Product WHERE TYPE='Laptop')
AND MAKER IN (SELECT MAKER FROM Product WHERE TYPE='PC')
AND MAKER IN (SELECT MAKER FROM Product WHERE TYPE='Printer');
Upvotes: 1
Reputation: 9074
Try following query:
select distinct(Maker) from product where Type="Printer" And Type="PC" And Type="Laptop"
Hope its helpful.
Upvotes: 0