如何使用SQL Server删除INNER JOIN?
我想在SQL Server 2008
使用INNER JOIN
进行删除。
但我得到这个错误,
Msg 156,Level 15,State 1,Line 15
在关键字'INNER'附近的语法不正确。
我的代码:
DELETE FROM WorkRecord2
INNER JOIN Employee ON EmployeeRun=EmployeeNo
WHERE Company = '1' AND Date = '2013-05-06'
您需要指定要删除的表格,这里是一个带有别名的版本:
DELETE w
FROM WorkRecord2 w
INNER JOIN Employee e
ON EmployeeRun=EmployeeNo
WHERE Company = '1' AND Date = '2013-05-06'
只需在要从中删除记录的位置在DELETE
和FROM
之间添加表名,因为我们必须指定要删除的表。 同时删除ORDER BY
子句,因为在删除记录时没有任何要订购的东西。
所以你的最终查询应该是这样的:
DELETE WorkRecord2
FROM WorkRecord2
INNER JOIN Employee
ON EmployeeRun=EmployeeNo
WHERE Company = '1'
AND Date = '2013-05-06';
尝试这个:
DELETE FROM WorkRecord2
FROM Employee
Where EmployeeRun=EmployeeNo
And Company = '1'
AND Date = '2013-05-06'
链接地址: http://www.djcxy.com/p/7659.html