我正在尝试在 access 2010 上运行以下 SQL 代码,但它在查询表达式中返回语法错误。有什么想法可能导致它吗?
提前致谢。
DELETE FROM Trn_done
WHERE (Trn_done.training =
SELECT Training
FROM Trainings
WHERE (Trainings.Area = '" & Area & "'))
您不应该 EQUAL 选择语句,以免选择中的多行导致代码中断。试试这个:
DELETE td
from Trn_done td
inner join Trainings t
on td.training = t.training
WHERE t.Area = '" & Area & "'
括号应该在嵌套 SQL 之前,如下所述
DELETE FROM Trn_done
WHERE Trn_done.training IN (
SELECT Training
FROM Trainings
WHERE (Trainings.Area = '" & Area & "')
)