Copy values from one column to another in the same table

前端 未结 7 1672
别那么骄傲
别那么骄傲 2020-12-02 05:08

How can I make a copy values from one column to another? I have:

Database name: list
number | test
123456 | somedata
123486 | somedata1
232344 | 34
         


        
7条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 05:40

    BEWARE : Order of update columns is critical

    GOOD: What I want saves existing Value of Status to PrevStatus

    UPDATE Collections SET  PrevStatus=Status, Status=44 WHERE ID=1487496;
    

    BAD: Status & PrevStatus both end up as 44

    UPDATE Collections SET  Status=44, PrevStatus=Status WHERE ID=1487496;
    

提交回复
热议问题