[英]How to Insert the same records in same table with different value under Id column? (Note : ID is primary key autoincrement column )
Suppose i have table level as 假设我的表级别为
ID name abbr countryid
1 None NN 11
2 Middle MD 33
3 Senior SN 33
4 Junior JN 22
No i want to insert the records of countryid 33 in same table with countryid 44 (Countryid 44 will be input parameter).But how to insert data under column ID? 不,我想将countryid 33的记录插入与countryid 44相同的表中(Countryid 44将作为输入参数)。但是如何在列ID下插入数据? as Id is autoincrement? 因为ID是自动递增的?
INSERT INTO Master_LevelsGrades(Id, LevelName, LevelAbbr, CountryId)
(
select ?? ,LevelName,LevelAbbr,@NewCountryId
from Master_LevelsGrades where CountryId=33
)
Just leave it out: 只需将其删除:
insert into Master_LevelsGrades (LevelName, LevelAbbr, CountryId)
select LevelName, LevelAbbr, @NewCountryId
from Master_LevelsGrades
where CountryId = 33;
It will be set automagically. 它将自动设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.