Dalma
2 months ago

Elegant way to fix duplicated many to many relationships

Posted 2 months ago by Dalma

Hi everyone I'm looking for some elegant way to correct an issue I created. I have a Roles table which is a Many-to-many relationship with Users. Due to a bug in my code I now have Users that have the same Role attached 6 or 7 times.

I'm looking for an elegant way to code an update to fix the following example

User: Jim Jones
Role: Technician
          Technician
          Technician

User:Peter Smith
Role: Technician
          Coordinator
          Designer
          Designer
          Designer

I guess basically I'm wanting to return a list of unique attached roles and then perform a sync of these ids

Please sign in or create an account to participate in this conversation.