使用 DB2、SQL PL 在联接中使用 NOT IN 排除数据
我需要帮助来制定正确的查询方法。
我需要为我的员工提供工作。如果他们在约会时没有空,他们就会被排除在可以获得工作的工作人员群体之外。我认为我想要做什么很清楚,但语法不正确:
INNER JOIN mySchema."STAFF" S
ON RS.STAFF_ID = S.STAFF_ID
AND RS.STAFF_ID NOT IN (SELECT SU.STAFF_ID
FROM mySchema."STAFF_UNAVAIL" SU
WHERE SU.UNAVAIL_DT = OUTSTANDING_DATE)
关于如何在连接中实现 NOT IN 而无需在连接中实际执行它的任何想法?
I need assistance in formulating the correct approach to a query.
I have staff members that I need to give work to. If they're not available on a date, they're excluded from the group of staff members that can get work. I think it's clear what I'm trying to do, but it's incorrect syntax:
INNER JOIN mySchema."STAFF" S
ON RS.STAFF_ID = S.STAFF_ID
AND RS.STAFF_ID NOT IN (SELECT SU.STAFF_ID
FROM mySchema."STAFF_UNAVAIL" SU
WHERE SU.UNAVAIL_DT = OUTSTANDING_DATE)
Any ideas on how one could achieve a NOT IN in a join without actually doing it in the join?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其放在连接之后的
where
子句中put it in a
where
clause after the joins