I'm trying to write a query along these lines:
UPDATE Table i2
SET value = 0
WHERE EXISTS (SELECT 1 FROM Table i1 WHERE i2.ID = 开发者_StackOverflow中文版i1.ID+1)
The problem is that I'm getting "Incorrect syntax near 'i2'." I'm guessing this is because it doesn't like giving a nickname to a table being updated, but if that's the case, how am I supposed to reference it?
An update does not only have to be on a table directly you can use an alias from a table referenced in the From clause.
UPDATE i2
SET value = 0
FROM Table i2
WHERE EXISTS (SELECT 1 FROM Table i1 WHERE i2.ID = i1.ID+1)
The "value" within the "SET" clause is a keyword of SQL.Further, your logic seems to be clearing all the "value"s except the first row, is it your goal?
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论