Update unique column of multiple rows , skip the duplicates

99 views Asked by At

Here is my main table Contacts

ID  | Name | Mobile
1   | Jai  | 123
2   | Dave | 456
3   | Peter| 789

ID -> Primary Key Column

Mobile -> an unique column

I have a new update request. The data resides in another table (say table dummy).

ID  | Name | Mobile
1   | Jai  | 456
2   | Dave | 789
3   | Peter| 123

To update data from table dummy to Contacts, I can easily fire an update query by joining these two tables and update the Mobile of Contacts. But it is possible only if the data to be updated from Mobile column of dummy table is unique.

That is, if the dummy table content is like below,

ID  | Name | Mobile | Status
1   | Jai  | 789    | 
2   | Dave | 456    | 
3   | Peter| 456    | 

In this case, I want to skip the rows 1 & 3 and update only the second row. And I need to update the STATUS column (Skipped or Updated).

Is it possible by few queries?

0

There are 0 answers