我想进行更新,只更新受影响的值,但我的更新查询有联接,因此where exists
无法正常工作。
update semester_workload tA
set tA.account = (SELECT DISTINCT (t2.WORKING - t2.WORKLOAD) FROM SEMESTER_WORKLOAD t1
join SEMESTER_WORKLOAD t2 on t1.ID_LECTURER = t2.ID_LECTURER
WHERE t2.ACADEMIC_SEMESTER = 'WS10' AND tA.ID_SW = t2.ID_SW);
where exists (SELECT 1 FROM SEMESTER_WORKLOAD t1
join SEMESTER_WORKLOAD t2 on t1.ID_LECTURER = t2.ID_LECTURER
WHERE t2.ACADEMIC_SEMESTER = 'WS10' AND tA.ID_SW = t2.ID_SW);
此代码无法正常工作,因为它显然无法在join子句后识别where exists
。
答案 0 :(得分:1)
只是一个简单的语法错误。在window.open
子句之前有一个多余的半冒号:
where exists
答案 1 :(得分:0)
你有一个&#34 ;;"过量。请注意,您不需要连接同一个表三次,您可以这样做:
UPDATE SEMESTER_WORKLOAD t1
set t1.account =
(
SELECT t2.WORKING - t2.WORKLOAD FROM SEMESTER_WORKLOAD t2
WHERE
(t1.ID_LECTURER, t1.ID_SW, 'WS10')=(t2.ID_LECTURER, t2.ID_SW, t2.ACADEMIC_SEMESTER)
FETCH FIRST ROWS ONLY
)
where exists
(
SELECT * FROM SEMESTER_WORKLOAD t2
WHERE
(t1.ID_LECTURER, t1.ID_SW, 'WS10')=(t2.ID_LECTURER, t2.ID_SW, t2.ACADEMIC_SEMESTER)
)