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 個しかありません。AttributeID という名前の Autoincrement Primery Key があり、エラーは次のとおりです。

"Field 'AttributeID' doesn't have a default value"
4

1 に答える 1

2

から余分な括弧を削除しますSELECT

INSERT INTO dc_tp_attributes
(Attribute_name,... interfaceid)

select Attribute_name, ... interfaceid
FROM dc_tp_attributes
Where testid=877
于 2014-02-08T06:15:21.203 に答える