Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I found out something strange which works

Update **X** SET field = 'bla'
from **X**

..which doesn't really make sense


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
343 views
Welcome To Ask or Share your Answers For Others

1 Answer

This general syntax is usually used for joining tables when updating (i.e., you want to update column c1 in table t1 based on column c2 in table t2). The general for is

UPDATE 
    t1
SET 
    t1.c1 = t2.c2, -- Just an example
    t1.c3 = 'something else' -- etc...
FROM 
    t1
[INNER | LEFT] JOIN t2 ON join_condition

On you example, you don't have a join clause, so it may look a bit funny, but as you noted, this is valid syntax.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...