I have an issue where a mistake resulted in a database table having both emails and GUIDs mixed in the ID column.
The table looks like this (simplified):
GUID | Value | Date
cf@a | 21 | 2016
mf@b | 42 | 2015
mf@b | 21 | 2016
1aXd | 3 | 2016
a7vf | 9 | 2015
Where for example user cf@a and user 1aXd are the same. The GUID - Email combinations are stored in another table. The emails are unique. Primary key is the ID(GUID) and the Date combined. My problem is, how do i update the table and merge the rows? the Value column of two merging rows should be summed.
So the example table assuming (cf@a -> 1aXd and mf@b -> 8bga and ui@q -> a7vf) would become:
GUID | Value | Date
1aXd | 24 | 2016 <-- merged, Value = 21+3
8bga | 42 | 2015 <-- converted to GUID
8bga | 21 | 2016 <-- converted to GUID
<-- one row removed (merged with the first one)
a7vf | 9 | 2015 <-- untouched
Thank you for any help!
I could do this in C# but i would rather learn how to do it with the MySQL Workbench