There are two dictionaries a and b, both of which have a common id 1, to realize the merging of dicts
and in mysqlselect a.id,a.MUT,b.neighbor from a full join b on a.id = b.id
The execution result is very similar
a = { "id": "1", "MUT": "1500", } b = { "id": "1", "neighbor": [2] } # result = addfunction(a,b) result = { "id": "1", "MUT": "1500", "neighbor": [2] }
How to achieve?
Consider complex situations:
a = [ { "id": "1", "MUT": "1500", }, { "id": "2", "MUT": "1500", } ] b = [ { "id": "1", "neighbor": [2] }, { "id": "3", "neighbor": [2] } ] # result = addfunction(a,b) result = [ { "id": "1", "MUT": "1500", "neighbor": [2] }, { "id": "2", "MUT": "1500", }, { "id": "3", "neighbor": [2] } ]
Because the join on condition may have multiple values, I found a code on stack and changed it.