update问题,我快要晕了!
create table ttt(
id int,
id1 int
)
create table ttt1(
id int,
id1 int
)
insert ttt1
select 1,0
insert ttt
select 1,1
union
select 1,2
union
select 1,3
update a set id1=a.id1+b.id1 from ttt1 a,ttt b where a.id=b.id
select * from ttt1
-----------
id id1 name
----------- ----------- --------
1 3 1
(所影响的行数为 1 行)
drop table ttt
drop table ttt1
--我想得到这种结果,用update怎么写啊?
id id1 name
----------- ----------- --------
1 6 1
(所影响的行数为 1 行)