日期:2014-05-16 浏览次数:20468 次
update a
set typeid=b.typeid
from Ta as a inner join Ta as b on a.class=b.class and a.type=b.type and a.Typeid is null and b.typeid is not null
--drop table test
create table test(id int, typeid int,type varchar(10),class int, list int)
insert into test
select 1 ,1 ,'asd', 13, null union all
select 2 ,2 ,'erer', 14, null union all
select 3 ,3 ,'trt', 15, null union all
select 4 ,null ,'asd', 13, 1 union all
select 5 ,null ,'erer', 14, 3 union all
select 6 ,null ,'trt', 15, 6
go
update test
set typeid = t.typeid
from test
inner join test t
on test.type = t.type and test.class = t.class