I wish to update a table where the value of a cell in tableB is a reference to a column name in tableA. It is a bit difficult to explain so below an example of the existing tables and the desired output:
Existing tables:
TableA
Dates | f1 | f2 | f3
1-1-2017 | 0 | 0 | 0
2-1-2017 | 0 | 0 | 0
3-1-2017 | 0 | 0 | 0
4-1-2017 | 0 | 0 | 0
TableB
Dates | Label | Counter
1-1-2017 | f1 | 1
1-1-2017 | f2 | 2
2-1-2017 | f1 | 1
2-1-2017 | f2 | 3
2-1-2017 | f3 | 2
3-1-2017 | f2 | 4
4-1-2017 | f3 | 2
4-1-2017 | f2 | 1
Desired output
TableA
Dates | f1 | f2 | f3
1-1-2017 | 1 | 2 | 0
2-1-2017 | 1 | 3 | 2
3-1-2017 | 0 | 0 | 4
4-1-2017 | 0 | 1 | 2
Is something like this possible in mysql?