SQL查询 - 根据column3的值设置column1的值为column2

时间:2021-07-16 04:27:56

I want to update column1 with values from column2 based the value of column3. This is what I have:

我想基于column3的值更新column1的值。这就是我所拥有的:

UPDATE Table SET Column1=Column2 WHERE Column3='Value'

UPDATE表SET Column1 = Column2 WHERE Column3 ='Value'

Is this possible?

这可能吗?

EDIT I tried this, but I didn't get the results I wanted (as in, none of my rows changed). I didn't get any errors though.

编辑我试过这个,但我没有得到我想要的结果(因为,没有我的行改变)。我没有得到任何错误。

UPDATE Figured out my error. Answer is below.

更新找出我的错误。答案如下。

1 个解决方案

#1


0  

Ah, Okay. Now I see where I went wrong. The Value of Column3 has the same name as Column2, so I messed up the order. This is what worked:

啊好吧。现在我明白我哪里出错了。 Column3的值与Column2的名称相同,因此我搞砸了订单。这是有效的:

UPDATE Table SET Column2=Column1 WHERE Column3='Value'

UPDATE表SET Column2 = Column1 WHERE Column3 ='Value'

#1


0  

Ah, Okay. Now I see where I went wrong. The Value of Column3 has the same name as Column2, so I messed up the order. This is what worked:

啊好吧。现在我明白我哪里出错了。 Column3的值与Column2的名称相同,因此我搞砸了订单。这是有效的:

UPDATE Table SET Column2=Column1 WHERE Column3='Value'

UPDATE表SET Column2 = Column1 WHERE Column3 ='Value'