1

我正在尝试在 access 2010 上运行以下 SQL 代码,但它在查询表达式中返回语法错误。有什么想法可能导致它吗?

提前致谢。

DELETE FROM Trn_done 
WHERE (Trn_done.training = 
SELECT Training  
FROM Trainings 
WHERE (Trainings.Area = '" & Area & "'))
4

2 回答 2

3

您不应该 EQUAL 选择语句,以免选择中的多行导致代码中断。试试这个:

DELETE td 
from Trn_done td
inner join Trainings t 
on td.training = t.training
WHERE t.Area = '" & Area & "'
于 2013-06-12T17:58:38.307 回答
3

括号应该在嵌套 SQL 之前,如下所述

DELETE FROM Trn_done
WHERE Trn_done.training IN (
    SELECT Training 
    FROM Trainings
    WHERE (Trainings.Area = '" & Area & "')
)
于 2013-06-12T18:03:24.767 回答