Update E set Status = 0
From EmployeeTest E
INNER Join SecurityTest S on S.SecurityID=E.EmployeeID and S.SecurityLevel<>'Admin'
INNER Join LOGINTest L on E.EmployeeID=L.LoginID and LastLogin < Add_Months(Cast(SysDate as date),25) and E.Status=1
我收到&#34; SQL命令未正确结束的错误&#34;
答案 0 :(得分:1)
改进答案:
UPDATE
(select e.status from EmployeeTest E
INNER Join SecurityTest S on S.SecurityID=E.EmployeeID and S.SecurityLevel<>'Admin'
INNER Join LOGINTest L on E.EmployeeID=L.LoginID and LastLogin < Add_Months(Cast(SysDate as date),25) and E.Status=1
) t
SET t.status = 0
答案 1 :(得分:1)
您可以使用EXISTS
执行此操作。我已移除CAST ( SYSDATE as DATE )
,因为SYSDATE
已经是日期类型
UPDATE employeetest o
SET o.status = 0
WHERE EXISTS (SELECT 1
FROM employeetest E
INNER JOIN securitytest S
ON S.securityid = E.employeeid
AND S.securitylevel <> 'Admin'
INNER JOIn logintest L
ON E.employeeid = L.loginid
AND lastlogin < ADD_MONTHS(SYSDATE, 25)
AND E.status = 1
AND employeeid = o.employeeid );