使用 NOT 运算符筛选使用多个表的数据

Using NOT operator to screen data using multiple tables

我有一道作业题要我找"What employees are not assigned to any HP computers? "

我试过以下方法:

select empname from Employee where empnum in
(select empnum from PC where comp in
  (select comp from computer where MFRNAME NOT LIKE 'HP'))

不过。我仍在从拥有两台计算机的员工 Douglas Dally 那里获取数据。其中一个是 HP,另一个不是 HP。但我想只能找到根本不使用任何 HP 计算机的员工。我怎样才能筛选出这个结果?

我在下面的数据中附上了 link。

如果您想让员工也不使用 HP 笔记本电脑,则可以使用 not exists

select empname
from Employee em
where not exists (
  select 1
  from PC p 
  join comp c on c.comp = p.comp 
  where em.empnum = p.empnum  
  and c.MFRNAME like '%HP%'
)  

这应该给你那些不使用像 HP 这样的计算机的员工,如果 HP 是绝对字符串那么你可以提到 c.MFRNAME = 'HP'