简化问题:
如果我有以下内容(其中 CN = 名称,UID = emp.ID,supervisor = emp.id 的主管):
CN          UID      supervisor  
Jerry       4         NULL
Dave        11        15    
Dan         12        16    
Jack        13        17    
Jason       14        11    
Tom         10        15    
Berry       16        12
我希望 Dave 和 Dan 都不在名单上,因为他们也是主管(第二名或更高)。
    SELECT
reports_accreditallfr.cn,
reports_accreditallfr.uid,
reports_accreditallfr.supervisor
FROM
reports_accreditallfr
WHERE
reports_accreditallfr.uid NOT IN ( reports_accreditallfr.supervisor)
我目前的陈述说明了一切。我猜我的 NOT IN 语句只是逐行工作,而不是扫描整个主管列。