假设我的表级别为
ID name abbr countryid
1 None NN 11
2 Middle MD 33
3 Senior SN 33
4 Junior JN 22
否,我想在与countryid 44相同的表中插入countryid 33的记录(Countryid 44将作为输入参数)。但是如何在列ID下插入数据?因为ID是自动递增的?
INSERT INTO Master_LevelsGrades(Id, LevelName, LevelAbbr, CountryId)
(
select ?? ,LevelName,LevelAbbr,@NewCountryId
from Master_LevelsGrades where CountryId=33
)
答案 0 :(得分:1)
只需将其删除:
insert into Master_LevelsGrades (LevelName, LevelAbbr, CountryId)
select LevelName, LevelAbbr, @NewCountryId
from Master_LevelsGrades
where CountryId = 33;
它将自动设置。