我正在尝试在excel中创建插入查询
coll_1 coll_2 coll_3
row1 row1 row1
row2 row2 row2
row3 row3 row3
="insert into customers ('" &A1&"','" & B1 & "','"&C1&"') values (" &A2&",'" & B2 & "','"&C2&"');"
我写的这个公式,我想输出为 插入客户('coll_1','coll_2','coll_3')值(row1,'row1','row1');
拖动公式后,列名称应保持不变
insert into customers (coll_1,coll_2,coll_3) values (row1,'row1','row1');
insert into customers (coll_1,coll_2,coll_3) values (row2,'row2','row2');
insert into customers (coll_1,coll_2,coll_3) values (row3,'row3','row3');
我希望列名保持不变,但值必须更改。
但是我得到了错误的结果
insert into customers (coll_1,coll_2,coll_3) values (row1,'row1','row1');
insert into customers (row1,'row1','row1') values (row2,'row2','row2');
insert into customers (row2,'row2','row2') values (row3,'row3','row3');
答案 0 :(得分:2)
您的公式看起来很接近。您只需要进行一些微小的更改,并将行锚定在插入的列部分中,因为当您向下拖动公式时,您不希望更改该行:
="INSERT INTO customers (" & A$1 & ", " & B$1 & ", " & C$1 &") VALUES ('" & A2 & "', '" & B2 & "', '" & C2 & "');"