```sql MERGE INTO pt_player_tribe AS target USING (SELECT ?1 AS player_id, ?2 AS tribe_id, ?3 AS world) AS source ON (target.player_id = source.player_id AND target.world = source.world) WHEN MATCHED AND target.tribe_id <> source.tribe_id THEN UPDATE SET tribe_id = source.tribe_id WHEN NOT MATCHED THEN INSERT (player_id, world, tribe_id) VALUES (source.player_id, source.world, source.tribe_id)```