我有这个问题:
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工作台。需要的是,如果有相同的order_num,它将覆盖该行。我还不知道怎么做那就是为什么我现在要做的就是TRUNCATE表然后再次在表中加载csv文件。
truncate table report;
因此,我将进行两次查询。有没有办法只在一个查询中查询文件中的截断和加载数据?如果可能的话,如果行具有相同的order_num,我怎么能覆盖一行?