您无法指定目标表格' s1'用于FROM子句中的更新

时间:2014-12-21 18:31:16

标签: sql sql-update

UPDATE sch_scores s1 
   SET s1.Score = '4' 
WHERE EXISTS (select * 
              from sch_scores s2 
              WHERE s2.ResultID = "24614" 
                AND s2.FormatID = "9" 
                AND s2.Score = "4")
  

您无法在FROM子句

中为更新指定目标表's1'

上述查询时出现错误。请问可能是什么问题?

3 个答案:

答案 0 :(得分:0)

UPDATE sch_scores 
SET Score = '4' 
WHERE EXISTS (select * 
              from sch_scores s2 
              WHERE s2.ResultID = "24614" 
                AND s2.FormatID = "9" 
                AND s2.Score = "4") 

答案 1 :(得分:0)

无需在update子句中指定实例(删除s1)

UPDATE sch_scores
    SET Score = '4' 
    WHERE EXISTS (select * from sch_scores s2 WHERE s2.ResultID = "24614" AND s2.FormatID = "9" AND s2.Score = "4")

答案 2 :(得分:0)

您无法在更新查询中提供别名“s1”。在更新时,没有必要给表提供临时名称吗?

 UPDATE sch_scores
   SET Score = '4' 
WHERE EXISTS (select * 
              from sch_scores s2 
              WHERE s2.ResultID = "24614" 
                AND s2.FormatID = "9" 
                AND s2.Score = "4")