表1 
Productid      Product1       time
1                    Cs5852       12-14
2                    Cs5853       12-14
4                    Cs5856       12-14
5                    Cs5857       12-14
6                    Cs5858       12-14
表2
Productid         Product2           Product3            time
1                      Cs5858            new6858           12-14
2                      Cs5858            new6858           12-14
3                      Cs5878            new5878           12-14对比表1 Product1 和表2 Product2中的产品编号,
如果相同如 Cs5858 = Cs5858 即取表2的 Product3 的 更新到 表1 对应的列。

解决方案 »

  1.   


    update a set a.product3=b.product3 from 表1 a,表2 b where a.product1=b.product2
      

  2.   


    表达错了,应该是对比表1 Product1 和表2 Product2中的产品编号,
    如果相同如 Cs5858 = Cs5858 即取表2的 Product3 的 更新到 表1 的Product1列。
      

  3.   

    update tb1 set tb1.Product1=tb2.product3 from 表1 tb1,表2 tb2 where tb1.product1=tb2.product2
      

  4.   

    update tb1 set tb1.Product1=tb2.product3 from 表1 tb1,表2 tb2 
    where tb1.product1=tb2.product2  and tb1.Productid=tb2.Productid 
      

  5.   

    达不到预期的效果。或者我这样说。从Product1读取数据查找 Product2 里的数据,匹配即取Product3更新到Product1.如果 
    id     Product1   Product2  Product3
     a          1               2              165
     b          2               1              167
     c          3               3              167ID为A的Product1  与ID为B的Product2  值一样 即取 id为B的 Product3值更新到 Product1
     
      

  6.   

    update a set a.Product1=b.product3 from 表1 a,表1 b 
    where a.product1=b.product2 and a.id<>b.id