How to delete double entries in the database?

Hello bubblers! :wave:t2:

I’m struggling with a problem… :confounded:

I will try to explain it below. :point_down:t2:

So in my app I want to give my users the ability to import a list of emails in the database and then be able to send an email to all those imported emails.

That part was easy peasy…

In my app I have a FileUploader and from it they can upload a file in .csv form

Then in the workflow I have:

When FileUploader value is changed —> Upload data as CSV

And that works perfectly. :white_check_mark:

Now the problem… :confounded:

If a user upload that same file but upgraded (for example before in that file there were 50 email and then they add 10 new email to that file) the problem that I have is that now in my database there are 110 emails :sweat_smile:

50 emails from the first time they uploaded the file


60 emails from the second time they uploaded that same file

How can I delete automatically the 50 emails that are already in my database and only keep the 10 new emails :question:

Any advice will be much appreciated :pray:t2:

Check this out:

Let me know if it is helpful, please.

@bestbubbledev - Youtube | Patreon | LinkedIn | Twitter

duplicates are eventual. you should utilize :unique elements which will filter out duplicates.

Hi mate, thanks for you reply!

Unfortunately that doesn’t help…

I watched that video many times.

He delete the duplicate one by one by creating a repeating group that shows only the duplicates.

That’s should be ok if you have to delete just a few… but what about 50+ ?

Also he used “Crate new thing” in his workflow, in that scenario he can use “Only when”, etc. to prevent duplicates.

But in my case by using “Upload data as CSV” action in my workflow the data from the .csv file my users upload, are automatically imported in my database.

That’s way I should need something I guess, that will let automatically delete the duplicate entries in my database…

You don’t want to consume any more usage from your app than you’d need to, more server side workflows would be extremely redundant. Just use :unique elements. You should allow duplicate entries, without checking if exists already skip, or whatever; redundant and wasteful. Then, when you’re searching for your list of users to email, it would just be something like Search for User’s email:unique elements

A few ideas.

  1. Upload to a temporary table, then run a backend workflow that iterates over that to add only ‘new’ emails
  2. Have a database trigger that checks for duplicates when a new email is added
1 Like

For starters I’d suggest to take above suggestions by @NigelG & @doug.burden into account.

This being said I’d use the method, in the link above, to identify duplicates and then run a Backend Workflow to delete them. Recursive workflow to delete them one by one until there’s none left.

1 Like

Hello could you solve this problem? If you could, can you please share the process. I am facing the same issue here.