SQL set values of one column equal to values of another column in the same table

前端 未结 5 2007
[愿得一人]
[愿得一人] 2021-02-02 05:11

I have a table with two DATETIME columns.

One of them is never NULL, but one of them is sometimes NULL.

I need to write a query which will set all the NULL rows

5条回答
  •  悲&欢浪女
    2021-02-02 05:36

    UPDATE YourTable
    SET ColumnB=ColumnA
    WHERE
    ColumnB IS NULL 
    AND ColumnA IS NOT NULL
    

提交回复
热议问题