I'm writing a SQL (Oracle) to update a table with the values in another table. But since there is a 2 column unique constraint, the update always failed. It is something like this:
Table A
- A_1
- A_2
- A_3
(There is a unique constraint for A_1 + A_3 )
Table B
- B_1
- B_2
Here is my current sql:
UPDATE A a
SET a.A_1 =
(SELECT b.B_1
FROM B b
WHERE a.A_2 = b.B_2
)
AND EXISTS
(SELECT b.B_1
FROM B b
WHERE a.a.A_2 = b.B_2
)
I want to skip the lines that violate the unique constraint but I don't know how to do it. Please advise. Thank you!