我试图通过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。
有一个AutoIncrement Primery Key Named命名的AttributeID,错误是
"Field 'AttributeID' doesn't have a default value"
答案 0 :(得分:2)
从SELECT
:
INSERT INTO dc_tp_attributes
(Attribute_name,... interfaceid)
select Attribute_name, ... interfaceid
FROM dc_tp_attributes
Where testid=877