Copy values from one column to another in the same table

前端 未结 7 1613
别那么骄傲
别那么骄傲 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;
    
    0 讨论(0)
提交回复
热议问题