문제

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"
도움이 되었습니까?

해결책

Remove the extra parenthesis from the SELECT:

INSERT INTO dc_tp_attributes
(Attribute_name,... interfaceid)

select Attribute_name, ... interfaceid
FROM dc_tp_attributes
Where testid=877
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top