用嵌套查询和连接查询查询供应了'W1'和'W2'号物资的公司编号
时间: 2024-01-17 12:06:15 浏览: 79
表的连接和嵌套查询
嵌套查询:
SELECT DISTINCT s.sid
FROM suppliers s
WHERE s.sname IN (SELECT sp.sname
FROM supply sp
WHERE sp.wid IN ('W1', 'W2'));
连接查询:
SELECT DISTINCT s.sid
FROM suppliers s
JOIN supply sp ON s.sname = sp.sname
WHERE sp.wid IN ('W1', 'W2');
阅读全文