我有一个运行查询的MS Access数据库,它可以从#34; TableX"具有相同的Employee_Key来自" TableY"。
问题是:Employee_Key列中的某些值为空。发生这种情况时,我应该按Employee_Email过滤,就像我在使用Employee_Key一样。
那么,如何验证Employee_Key是否为空白,当它实际为空白时,如何使用不同的过滤器(电子邮件)运行另一个查询?
Ps:一旦这项任务来自我的工作,我现在没有确切的查询。
答案 0 :(得分:0)
select x.*
from tableX x
join tableY y on
(
'' not in (x.Employee_Key, y.Employee_Key)
and x.Employee_Key = y.Employee_Key
)
or
(
'' in (x.Employee_Key, y.Employee_Key)
and x.Employee_Email = y.Employee_Email
)
答案 1 :(得分:0)
如果我理解正确的逻辑:
select x.*, y.*
from tableX as x inner join
tabley as y
on x.employee_key = y.employee_key or
(x.employee_key is null and x.employee_email = y.employee_email);