merge where and update for upsert