SQL query for this problem I have one single table.

Table A has two columns

id, sample_id

an id will be associated with multiple sample_id..However both values i.e combined are unique

example,

id, sample_id
1, 10
1, 11
1, 12
2, 9
2, 10
2, 11


Now i want to update all the records of "1" to "2" provided it doesn't have a record in "2"

How to do it? Expected Result

id, sample_id
1, 10
1, 11
2, 12
2, 9
2, 10
2, 11


Thanks
UPDATE test t1
LEFT JOIN test t2 ON t1.sample_id = t2.sample_id AND t2.id = 2
SET t1.id = 2
WHERE t2.id IS NULL;


fiddle