I have a table:
| foo | bar |
+-----+-----+
| abc | 4 |
| def | 1 |
| ghi | 2 |
foo
has unique index.
I want to load a file into this table summing bar
values of duplicates by foo
column:
abc \t 7
ghi \t 3
jkl \t 4
Is there any way to sum values in duplicate rows during LOAD DATA
?
This command replaces old values in a row:
LOAD DATA LOCAL INFILE 'file.txt' REPLACE
INTO TABLE `table` FIELDS TERMINATED BY '\t' (`foo`,`bar`);
I want to have a table like this:
| foo | bar |
+-----+-----+
| abc | 11 |
| def | 1 |
| ghi | 5 |
| jkl | 4 |