我有一个表需要更新,基本上是重复数据,除了一列数据。
我的表名是tblSupporters
我的专栏是
ID, SYear, Type, Support Location, City, State, Info.
我需要复制SYear
等于2012的表格中的数据并插入同一个表格,但将SYear
更改为2013。
我知道这很简单,但我对此很陌生。
答案 0 :(得分:3)
只需使用insert . . . select
:
insert into tblSupporters(ID, SYear, Type, Support Location, City, State, Info)
select ID, 2013 as SYear, Type, Support Location, City, State, Info
from tblSupporters
where SYear = 2012;
我的猜测是id
会自动分配,因此您可能真的需要:
insert into tblSupporters(SYear, Type, Support Location, City, State, Info)
select 2013 as SYear, Type, Support Location, City, State, Info
from tblSupporters
where SYear = 2012;