找到已购买冰箱等零件的客户名称(part_description)

时间:2013-10-10 03:52:44

标签: sql

请帮助解决这个问题。我尝试使用join.can在Microsoft Access 2010中解决此问题。我通过创建视图然后应用简单查询来解决此问题

这是表结构:

客户

custnum,custname,balance,repnum

订单

ordernum,partnum,numordered,quotedprice

订单

ordernum,orderdate,customernum

部分

partnum,description,onhand,class,warehouse,price

rep

repnum,佣金

2 个答案:

答案 0 :(得分:0)

SELECT DISTINCT c.custname
FROM ((orderline AS ol 
INNER JOIN [part] AS p ON ol.partnum  = p.partnum)
INNER JOIN [order] AS o ON ol.ordernum  = o.ordernum)
INNER JOIN customer AS c ON o.customernum = c.custnum
WHERE p.description = 'refrigerator'

答案 1 :(得分:0)

SELECT custname FROM customer WHERE custnum=
ANY(SELECT custnum FROM [order] WHERE ordernum=
    ANY(SELECT ordernum FROM orderline WHERE partnum=
       ANY(SELECT partnum FROM [part] WHERE description ='refrigerator')
));