主1     主2     主3     主4     主5     主6    主7   主8  主9   名字
199810 ABC EEE GGG D1122   USD 04   a    A1 奥特曼
199810 ABC EEE GGG D1122   USD 04   j    A2 七龙珠
199810 ABC EEE GGG D1122   USD 04   c    A3 花仙子
199810 ABC FFF GGG D1122   USD 04   a    A4
199810 ABC FFF GGG D1122   USD 04   a    A5 阿拉蕾
199810 ABC FFF GGG D1122   USD 04   j    A6   要求以(主1-主8)为条件,将其条件相同的数据的名字更变为相同名字

解决方案 »

  1.   

    -- try it
    update yourTable a
       set name = (select name from yourTable b where a.主1=b.主1 and ..... a.主8=b.主8 and b.name is not null)
     where a.name is null
      

  2.   

    update tabelname t
       set 名字 = (select max(名字)
                     from tablename
                    where 主1 = t.主1, 主2 = t.主2, 主3 = t.主3, 主4 = t.主4,
                    主5 = t.主5, 主6 = t.主6, 主7 = t.主7 主8 = t.主8)
      

  3.   

    update table_a t --主表
    set 名字 = (select 名字 from (select 主1,主2,主3,主4,主5,主6,主7,主8,主9,max(名字)
                                  from table_a
                                  group by 主1,主2,主3,主4,主5,主6,主7,主8,主9) table_xx --按照9个主键统计出的表
                where t.主1 = table_xx.主1
                and t.主2 = table_xx.主2
                and t.主3 = table_xx.主3
                and t.主4 = table_xx.主4
                and t.主5 = table_xx.主5
                and t.主6 = table_xx.主6
                and t.主7 = table_xx.主7
                and t.主8 = table_xx.主8
                and t.主9 = table_xx.主9
    )