2014-10-19 98 views
-1

我有一张表,我需要更新基本上是重复的数据,除了一列数据。从表中插入数据

我的表名是tblSupporters

我列

ID, SYear, Type, Support Location, City, State, Info. 

我需要将数据从我的表复制其中SYear等于2012,并插入到相同的表,但改变SYear至2013年

我知道这很简单,但我对此很陌生。

回答

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; 
+0

你猜对有关的ID。很棒!非常感谢!! – leta 2014-10-19 17:36:19