我需要找到飛機的名字,使得所有飛行員認證來操作它們收入超過60000
查詢我寫道:
select aname
from employee join certified
on employee.eid=certified.eid
join aircraft
on certified.aid=aircraft.aid
where salary>60000;
但是,如果有超過60000美元薪水的飛行員返航,難度在於我需要找到所有飛行員賺取超過60000才顯示aname。
我需要找到飛機的名字,使得所有飛行員認證來操作它們收入超過60000
查詢我寫道:
select aname
from employee join certified
on employee.eid=certified.eid
join aircraft
on certified.aid=aircraft.aid
where salary>60000;
但是,如果有超過60000美元薪水的飛行員返航,難度在於我需要找到所有飛行員賺取超過60000才顯示aname。
SELECT aname FROM Aircraft where NOT EXISTS (SELECT eid FROM Employee AS e INNER JOIN Certified AS c ON c.eid=e.eid WHERE salary<60000 AND aid=Aircraft.aid)
選擇 aname FROM 飛機 WHERE EXISTS ( SELECT * FROM Certified C INNER JOIN Employee E ON E.eid = C.eid AN D E.salary> 60000 WHERE C.aid = A.aid )
在@Tom H的查詢中,把所有沒有員工的飛機名稱 – Vishal
where salary> 60000; – Pudding
你可以使用'WHERE .. IN ALL(subquery)'。檢查文檔:https://dev.mysql.com/doc/refman/5.5/en/all-subqueries.html – hjpotter92
對不起,糾正它@Pudding – mightyWOZ