2014-10-19 128 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