数据库字段值复制sql

业务场景:当某个功能后期程序换字段时,新的代码跑老的数据会产生空值(set和get的不一致),这时就要求对新字段进行赋值,此处的

exe_enter_operator_name ,
exe_enter_time  为新启动的字段名称
nurse_sign_name  
copy_sign_time  为老数据
UPDATE  in_doc_order_sheet   SET  exe_enter_operator_name = ( SELECT  nurse_sign_name  FROM  in_doc_order_status   WHERE  in_doc_order_sheet.in_doc_order_id= in_doc_order_status.in_doc_order_id ) where in_doc_order_sheet.exe_enter_operator_name is NULL;
UPDATE  in_doc_order_sheet   SET  exe_enter_time = ( SELECT  copy_sign_time  FROM  in_doc_order_status   WHERE  in_doc_order_sheet.in_doc_order_id= in_doc_order_status.in_doc_order_id ) where in_doc_order_sheet.exe_enter_time is NULL

  

posted @ 2021-04-01 16:52  青春的西瓜  阅读(364)  评论(0编辑  收藏  举报