当前位置:网站首页>SQL assigns the field value of data table B to a column in data table a

SQL assigns the field value of data table B to a column in data table a

2022-06-26 13:12:00 shmilyhq

Data sheet table1 --》 Field name ,age,def,org_code,del_flag ,id
Data sheet table2 code, table1_id, own,del_flag

The code is as follows

update table2 b  
    left join (
       select distinct name ,org_code,batch_no from table1 where del_flag = 0
   ) a on a.id= b.table1_id
   set b.code= a.name ,b.own= a.org_code
    where  b.del_flag = 0 and (b.codeis null or b.ownis null);

My humble opinion ----- For reference only !

原网站

版权声明
本文为[shmilyhq]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261222578558.html