2

I am trying to insert multiple rows via sql query scenario is this : There are multiple attributes against 1 testID and I want to copy attributes of one test to another test by giving their TestID here is the query I am trying but its not working at all

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

Here I am copying attributes of testID=877 to testID=635, test with ID 877 has 10 attributes and test with testID 635 have just 1. There is an Autoincrement Primery Key Named AttributeID and the error is

"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 回答