create table t3(id3 int identity(1,1),id1 int,id2 int,name2 varchar(10))insert into t3(id1,id2,name2)
select id1,id2,name2
from t1,t2
where t1.g1=t2.g1
select id1,id2,name2
from t1,t2
where t1.g1=t2.g1
调试欢乐多
select id3=identity(int,1,1), a.id1,b.id2,b.name2 into #temp from t1 a,t2 b
insert t3 select * from #temp
drop table #temp
此时若T1改变如下:
T1
id1 name1 G1
1 w1 1
2 w2 1删除3 w3 2
4 w4 2
5 w5 1 如何使T3也做相应的改变呢?T3
id3 id1 id2 name2
1 1 1 aa
2 5 1 aa
3 1 2 bb
4 5 2 bb
5 3 3 cc
6 4 3 cc
select id1,id2,name
from t1,t2
where t1.g1=t2.g1
1 1 aa
5 1 aa
1 2 bb
5 2 bb
3 3 cc
4 3 cc