Sql Server根据记录集批量更新数据库

时间:2021-09-29 04:46:09

 

1  update    t1    set    t1.value = t2.value    from    t2    where    t1.id = t2.id

 

 

1  update  jbsite_class   set  topicnum  =   count  
2  from  ( select  t2.classid, count   from  (
3  select   distinct  classid, count ( * as   count
4  from  jbsite_product
5  group   by  classid) t2
6  inner   join   jbsite_product  on  jbsite_product.id  =  t2.classid
7  ) b  where  jbsite_class.id = b.classid