If you are willing to use just the minimum or maximum value, you can simply use update
:
update table_2 t2
set la_id = (select min(t1.la_id)
from table_1 t1 join
table_1 t12
on t1.state = t12.state and t1.city = t12.city and t1.address = t12.address
where t12.la_id = t2.la_id
)
where la_id <> (select min(t1.la_id)
from table_1 t1 join
table_1 t12
on t1.state = t12.state and t1.city = t12.city and t1.address = t12.address
where t12.la_id = t2.la_id
);
I'm not sure how you are choosing 572
and 082
for the specific ids you want when there are duplicates. This would choose 300
and 026
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…