我使用以下SQL从.csv文件中的列导入数据:
$insert_query_two = "LOAD DATA LOCAL INFILE 'mgaptoolfile.csv'
INTO table mgap_orders
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
IGNORE 3 LINES
(@dummy,@dummy,@dummy,@dummy,@dummy,
account_manager_id,
account_manager_email,mgap_ska_id,mgap_ska_id_name,@dummy,
@dummy,@dummy,@dummy,@dummy,
mgap_ska_record_type,mgap_ska_report_category,@dummy,mgap_actual_sales_per,
mgap_growth,mgap_expected,mgap_actual,mgap_recovery,
mgap_item_number,mgap_item_type,mgap_item_catalog_number,mgap_item_vendor,
mgap_item_description,mgap_exp_last3,mgap_act_last3,@dummy,mgap_item_percent_purchased,mgap_item_sales,@dummy,@dummy,rep_action
)
";
@dummy变量表示.csv文件中跳过的列
我将@dummy变量之一更改为我已添加到表中的新字段,所以现在看起来像这样:
$insert_query_two = "LOAD DATA LOCAL INFILE 'mgaptoolfile.csv'
INTO table mgap_orders
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
IGNORE 3 LINES
(@dummy,@dummy,@dummy,@dummy,@dummy,
account_manager_id,
account_manager_email,mgap_ska_id,mgap_ska_id_name,@dummy,
@dummy,@dummy,@dummy,@dummy,
mgap_ska_record_type,mgap_ska_report_category,mgap_expected_sales,mgap_actual_sales_per,
mgap_growth,mgap_expected,mgap_actual,mgap_recovery,
mgap_item_number,mgap_item_type,mgap_item_catalog_number,mgap_item_vendor,
mgap_item_description,mgap_exp_last3,mgap_act_last3,@dummy,mgap_item_percent_purchased,mgap_item_sales,@dummy,@dummy,rep_action)
";
正如你在下面的行中看到的那样(@ dummy,@ dummy,@ dummy,@ duumy)我用mgap_expected_sales替换了一个@dummy变量。
我已将此新字段添加到我的表中,但现在没有数据导入到表中。
有没有人有任何想法可能会发生这种情况?
提前致谢。