我有100,000条记录,必须在codeigniter
中执行批量插入。但是得到以下错误。任何人都能为我提供解决方案吗?
错误号码:1064
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 近 '' scheduleId”, '用户id', '用户类型', '活性', 'createdBy', 'createdOn', 'updatedBy') ('第1行
INSERT INTO scheduled_user_details('scheduleId','userId','userType','active','createdBy','createdOn','updatedBy') ()
VALUES ('600','401','lead','1','81114','2016-01-19 13:01:55','81114'), ('600','402','lead','1','81114','2016-01-19 13:01:55','81114')
答案 0 :(得分:1)
附近有错误 '' scheduleId''用户id'' USERTYPE''有源'' createdBy',& #39; createdOn'' updatedBy&#39)
很明显,您在查询中使用空()
。您需要删除此括号()
第二次,从列名中删除引号并使用反引号。
更新1:
根据您的意见,您正在使用CodeIgniter Framework。你不能像你的例子一样使用批量查询:
FROM the CodeIgniter User Guide:
您可以使用批量插入查询:
$data = array(
array(
'scheduleId' => '600' ,
'userId' => '401' ,
'userType' => 'lead',
'active' => '1',
'createdBy' => '81114',
'createdOn' => '2016-01-19 13:01:55',
'updatedBy' => '81114'
),
array(
'scheduleId' => '600' ,
'userId' => '402' ,
'userType' => 'lead',
'active' => '1',
'createdBy' => '81114',
'createdOn' => '2016-01-19 13:01:55',
'updatedBy' => '81114'
)
);
$this->_ci->db->insert_batch('scheduled_user_details', $data);
答案 1 :(得分:1)
更改此
INSERT INTO scheduled_user_details('scheduleId','userId','userType','active','createdBy','createdOn','updatedBy') ()
VALUES ('600','401','lead','1','81114','2016-01-19 13:01:55','81114'), ('600','402','lead','1','81114','2016-01-19 13:01:55','81114')
到这个
INSERT INTO scheduled_user_details(scheduleId,userId,userType,active,createdBy,createdOn,updatedBy)
VALUES ('600','401','lead','1','81114','2016-01-19 13:01:55','81114'),
('600','402','lead','1','81114','2016-01-19 13:01:55','81114')
删除值
()
附近的值
当您插入一批数据时,请使用 INSERT IGNORE INTO