交界处 table - 更换除外
Junction table - EXCEPT replacement
我有如下所示的关系,员工和培训,
每个员工都可以参加任何培训,所以这是一个基本的 M:M 到 1:M M:1 东西。
我有一个 select 员工的组合框,我想要两个列表框来列出已完成的培训和可用的培训
像这样:
然后有两个按钮将 select 从一个列表框移动到另一个列表框并相应地更改记录。
我已查询以列出该员工参加的所有培训:
SELECT Training.Name, Training.Trainer, Training.Cost, Training.Type, Training.[Length(Day)]
FROM Training INNER JOIN Participation ON Training.[Training ID] = Participation.Training
WHERE (((Participation.Employee)=[Forms]![Add Training 2]![cboEmp]))
ORDER BY Training.Name;
我在 selecting 所有训练和过滤掉已经在 SQL 查询中 selected 的训练时遇到问题,上面的简单 EXCEPT 可以工作,但 ACCESS不支持。
这就是我想要的:
SELECT Training.Name, Training.Trainer, Training.Cost, Training.Type, Training.[Length(Day)]
FROM Training
EXCEPT
SELECT Training.Name, Training.Trainer, Training.Cost, Training.Type, Training.[Length(Day)]=
FROM Training INNER JOIN Participation ON Training.[Training ID] = Participation.Training
WHERE (((Participation.Employee)=[Forms]![Add Training 2]![cboEmp]))
ORDER BY Training.Name;
您可以只使用 not exists
或 not in
:
SELECT Training.Name, Training.Trainer, Training.Cost, Training.Type, Training.[Length(Day)]
FROM Training
WHERE Training.TrainingId NOT IN (SELECT Participation.Training
FROM Participation
WHERE Participation.Employee = [Forms]![Add Training 2]![cboEmp]
)
ORDER BY Training.Name;
我有如下所示的关系,员工和培训, 每个员工都可以参加任何培训,所以这是一个基本的 M:M 到 1:M M:1 东西。
像这样:
然后有两个按钮将 select 从一个列表框移动到另一个列表框并相应地更改记录。
我已查询以列出该员工参加的所有培训:
SELECT Training.Name, Training.Trainer, Training.Cost, Training.Type, Training.[Length(Day)]
FROM Training INNER JOIN Participation ON Training.[Training ID] = Participation.Training
WHERE (((Participation.Employee)=[Forms]![Add Training 2]![cboEmp]))
ORDER BY Training.Name;
我在 selecting 所有训练和过滤掉已经在 SQL 查询中 selected 的训练时遇到问题,上面的简单 EXCEPT 可以工作,但 ACCESS不支持。
这就是我想要的:
SELECT Training.Name, Training.Trainer, Training.Cost, Training.Type, Training.[Length(Day)]
FROM Training
EXCEPT
SELECT Training.Name, Training.Trainer, Training.Cost, Training.Type, Training.[Length(Day)]=
FROM Training INNER JOIN Participation ON Training.[Training ID] = Participation.Training
WHERE (((Participation.Employee)=[Forms]![Add Training 2]![cboEmp]))
ORDER BY Training.Name;
您可以只使用 not exists
或 not in
:
SELECT Training.Name, Training.Trainer, Training.Cost, Training.Type, Training.[Length(Day)]
FROM Training
WHERE Training.TrainingId NOT IN (SELECT Participation.Training
FROM Participation
WHERE Participation.Employee = [Forms]![Add Training 2]![cboEmp]
)
ORDER BY Training.Name;