I have a database (table name is campaigns_eventfire) with duplicate events for contacts and I'd like to delete all duplicates so each contact id has just one event.
Here's what my table looks like:
| ID | CONTACT_ID | EVENT_ID | SCHEDULED |
|---|---|---|---|
| 1 | 8,854 | 1,187 | 02/08/2 06:00 |
| 2 | 8,854 | 1,187 | 02/08/2 06:00 |
| 3 | 8,854 | 1,187 | 02/08/2 06:00 |
| 4 | 8,854 | 1,187 | 02/08/2 06:00 |
| 5 | 8,854 | 1,187 | 02/08/2 06:00 |
| 6 | 8,854 | 1,187 | 02/08/2 06:00 |
| 7 | 8,854 | 1,187 | 02/08/2 06:00 |
| 8 | 8,854 | 1,187 | 02/08/2 06:00 |
| 9 | 8,854 | 1,187 | 02/08/2 06:00 |
| 10 | 8,854 | 1,187 | 02/08/2 06:00 |
| 11 | 8,854 | 1,187 | 02/08/2 06:00 |
| 12 | 8,854 | 1,187 | 02/08/2 06:00 |
| 13 | 9,124 | 1,145 | 02/08/2 06:00 |
| 14 | 9,124 | 1,145 | 02/08/2 06:00 |
| 15 | 10,570 | 924 | 02/08/2 06:00 |
| 16 | 10,570 | 924 | 02/08/2 06:00 |
Contact_ID 8854 with event_id 1187 appears twelve times which means that the contact is scheduled for the same event 12 times which is wrong.
Contact_ID 9124 with event_id 1145 appears two times.
Contact_ID 10,570 with event_id 924 appears two times
Here's what I want the table to look like after deletion.
| ID | CONTACT_ID | EVENT_ID | SCHEDULED |
|---|---|---|---|
| 1 | 8,854 | 1,187 | 02/08/2 06:00 |
| 13 | 9,124 | 1,145 | 02/08/2 06:00 |
| 15 | 10,570 | 924 | 02/08/2 06:00 |
It doesn't matter which ID gets deleted, so long as the duplicates are removed. I have around 600 affected records so deleting one at a time is just not practical.
Thanks.