所以我有 3 个表,我需要从前 2 个表中计算一个值,然后用该值更新第三个表中的一个字段,我遇到了一个错误。
UPDATE Characters AS c
SET c.Total_DKP = (
(SELECT c.Initial_DKP
FROM c
WHERE c.Name='harrian')-
(SELECT SUM(a.DKP_Change)
FROM Attendance AS a
WHERE a.Name = 'harrian')
)
WHERE c.Name = 'harrian' ;
它给出了错误
Table 'harrian.c' doesn't exist
但是当我跑步时
UPDATE Characters AS c
SET c.Total_DKP = ( SELECT SUM(a.DKP_Change)
FROM Attendance AS a
WHERE a.Name = 'harrian'
)
WHERE c.Name = 'harrian'
我没有问题,谁能告诉我第一个块有什么问题?
这是完整的查询-
UPDATE Characters AS c
SET c.Total_DKP = (
(SELECT c.Inital_DKP FROM Characters AS c WHERE c.Name = 'harrian')
+(SELECT SUM(a.DKP_Change) FROM Attendance AS a WHERE a.Name = 'harrian')
+(SELECT SUM(b.Cost) FROM Raid_Drops AS b WHERE b.Player_Name = 'harrian')
)
WHERE c.Name = 'harrian' ;
我现在收到此错误
You can't specify target table 'c' for update in FROM clause