Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL查询截断表,然后插入_Mysql_Sql_Csv_Truncate_Workbench - Fatal编程技术网

MySQL查询截断表,然后插入

MySQL查询截断表,然后插入,mysql,sql,csv,truncate,workbench,Mysql,Sql,Csv,Truncate,Workbench,我有一个疑问: load data local infile 'C:/Users/vissia18/Desktop/report-1394508761.csv' into table report fields terminated by ',' enclosed by '"' lines terminated by '\n' ignore 1 lines (order_num, sales_order_item, sku, description, unit_price, tax_amo

我有一个疑问:

load data local infile 'C:/Users/vissia18/Desktop/report-1394508761.csv' into table report    fields terminated by ','
enclosed by '"'
lines terminated by '\n'
ignore 1 lines
(order_num, sales_order_item, sku, description, unit_price, tax_amount, coupon_money_value, coupon_percent, coupon_refundable, paid_price, created_date, created_time, wrapping_price, refund_type, refund_money, refund_shipping_money, refunded_other_money, refund_info, bank_reference, cart_rule_discount, return_tracking_num, shipment_type, current_unit_cost, created_unit_cost, item_status, item_status_date, canceled_reason, coupon_code, cust_id, cust_first_name, cust_last_name, cust_email, cust_gender, payment_method, grand_total);
我正在使用MySQL工作台。需要的是,如果存在相同的订单号,它将覆盖该行。我仍然不知道怎么做,这就是为什么我现在要做的是截断表,然后在表中再次加载csv文件

truncate table report;

因此,我将执行两个查询。是否有一种方法可以在一次查询中同时查询文件中的截断和加载数据?如果可能的话,如果一行具有相同的订单号,我如何覆盖该行?

两个查询有什么问题?用户将与之无关。他只想点击,然后瞧,两个查询都应该执行。你怎么运行这个程序?为什么你不能把这两个查询放在按钮点击之类的事件中呢?如果是一个程序,我可以。他只是在用工作台什么的。我将创建数据库和查询,然后将其传递给他。但他不懂IT这就是为什么我需要把它简单化。然后做一个SP。。在SP中调用这两个查询。