2
我嘗試插入通過SQL查詢多行 的情況是這樣的: 有反對1 testID
多個屬性,我想在這裏給他們TestID
一個測試的屬性複製到另一個考驗是查詢我想,但在所有複製行
INSERT INTO dc_tp_attributes
(Attribute_name,acronym,active,description,testId,
subdepartmentid,
DOrder,Attribute_type,D_A_formula,D_A_formula_desc,
Linesno,DefaultValue,interfaced,ClientID,Enteredby,
Enteredon,drived,parentid,heading,print,interfaceid)
select Attribute_name,acronym,active,description,
635,subdepartmentid,DOrder,Attribute_type,D_A_formula,
D_A_formula_desc,Linesno,DefaultValue,interfaced,
ClientID,Enteredby,Enteredon,drived,parentid,
heading,print,interfaceid
FROM dc_tp_attributes
Where testid=877
這裏它不工作,我複製的testID=877
屬性testID=635
,ID爲877測試有10個屬性和測試與testID 635剛剛1 有一個自動增量Primery關鍵命名爲AttributeID,錯誤爲
"Field 'AttributeID' doesn't have a default value"
它說:「字段屬性Id沒有默認值」 ......有一個自動增量主鍵名爲屬性ID在該表 –
奇怪 - 如果排除了'AUTO_INCREMENT'列,它應該用'insert into ... select'添加新的Ids - 參見[小提琴示例](http://www.sqlfiddle.com/#!2/0b024/1)。你確定auto_increment?例如我可以重複這裏[這裏](http://www.sqlfiddle.com/#!2/172d3/1) – StuartLC
現在它的工作,非常感謝你的幫助.. :) –