我想设置一个查询,询问“向我显示表用户中未在表雇员中找到的所有人员”。我正在寻找失业者
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
data = pd.DataFrame(data={'x':index, 'y':colonnes, 'z':score})
data = data.pivot(index='x', columns='y', values='z')
sns.heatmap(data)
plt.show()
表通过SELECT user.name,user.surname,user.user_id,employee.employee_id,employee.user_id
FROM user
INNER JOIN employee ON employee.user_id=user.user_id
WHERE user.user_id <> employee.user_id
-> user.user_id
答案 0 :(得分:1)
您可以使用outer join
进行这种查询,并检查外部表中是否为空值。
这里是对查询的略微修改,将其更改为外部联接,并寻找返回的空值。
编辑:根据此答案的注释,我还添加了第三个表,其中包含manager
表。
SELECT
user.name,user.surname,user.user_id,employee.employee_id,employee.user_id
FROM
user
LEFT OUTER JOIN employee
ON employee.user_id=user.user_id
LEFT OUTER JOIN manager
ON manager.user_id=user.user_id
WHERE
-- The columns from employee and manager get returned with null values if there is no match
employee.user_id is null
and manager.user_id is null