Modifying multiple records - foreign key with multiple links


#1

Hi,

We have two tables: users and topics. They’re linked in a many-to-many fashion (I can write to Tim about pancakes and pizza, Ann about pizza and Alex and pancakes).

I want to be able to add a topic to a subset of selected users. For example, I set filters and get 100 users that I have not written to about pizza (some of them received emails about pancakes, others about pancakes and nails, others haven’t received anything). I want to “add” pizza to their topic.

Before:

  • mark - pancakes
  • tom - pancakes, nails
  • jerry - {nothing}

After:

  • mark - pancakes, pizza
  • tom - pancakes, nails, pizza
  • jerry - pizza

How do I do it? We have the db structure ready, just need to modify the records.