INSERT INTO返回操作数应包含1列

时间:2015-11-22 22:17:42

标签: php mysql

我将数据从Excel工作表插入数据库。单个查询中的所有行。

我搜索并发现要在单个查询中插入多行,我必须像这样进行查询

INSERT INTO table_name(c1,c2) VALUES( (value1,value2),(value1,value2))

这是INSERT INTO

single row查询的查询方式
INSERT INTO December_2015(S_No,Zone,State,City2,VM_Town,Distibutor_Code,Distributor_Name,Dealer_Code,Dealer_Name,Category,Address,Location,Contact,Mobile_No,Visit_1,Visit_2,Visit_3,Visit_4,Visit_5,Visit_6) VALUES(('1','South','Telanagana','Hyderabad','Y','1006704','Sai Santhoshi Enterprises','TG000999','Sree Laxmi Mobiles','A','F4,anthem Arcade,gujarathi Galli,koti ','Koti','Rajesh','8790575680','7-Nov','18-Nov','28-Nov','','',''))

当我有多行要插入INSERT INTO multiple rows查询时,INSERT INTO December_2015(S_No,Zone,State,City2,VM_Town,Distibutor_Code,Distributor_Name,Dealer_Code,Dealer_Name,Category,Address,Location,Contact,Mobile_No,Visit_1,Visit_2,Visit_3,Visit_4,Visit_5,Visit_6) VALUES(('1','South','Telanagana','Hyderabad','Y','1006704','Sai Santhoshi Enterprises','TG000999','Sree Laxmi Mobiles','A','F4,anthem Arcade,gujarathi Galli,koti ','Koti','Rajesh','8790575680','7-Nov','18-Nov','28-Nov','','',''),('2','South','Telanagana','Hyderabad','Y','1006704','Sai Santhoshi Enterprises','TG000997','National Marketing','C','Shop No:28,2nd Floor,anthem Arcade,Gujarati Galli,koti ','Koti','Ramesh','9989014926','7-Nov','18-Nov','28-Nov','','',''))

Operand should contain 1 column(s)

这就是为什么我的查询中有两个括号,但它返回错误td.innerHTML = jsData[i].Location; td = tr.insertCell(tr.cells.length); td.innerHTML = jsData[i].Year; td = tr.insertCell(tr.cells.length); etc. 究竟是什么问题?

1 个答案:

答案 0 :(得分:2)

您不需要外部支架。只是围绕每条记录括起来。

INSERT INTO table_name(col1, col2, col3) VALUES (1,2,3), (4,5,6);