Using Double SplitinBatches Node with MySQL Node

Here is my usecase:

  1. Cron Job run every x days. It select all the email address from the database. (I’ll replace start node with cronjob)
  2. Then SplitinBatches Node split all the data into batches. (Currently Batch size is 1)
  3. Then goes into Another MySQL Node(Number 3) (Checking for that email got from MySQL Node (Number 1) inside different table)
  4. Then It’ll send an Email

The Problem:
As you can see in the below screenshot, Node Number 3 has 2 Data where Node 4 & Node 5 have only one. Which means the data isn’t fully coming to the end.

What I want to achieve:
I’m getting the email from one MySQL table then check whether that email is present in another table. If it doesn’t present. I want to send an email to those email address which isn’t present.

Workflow Code

Hey @mcnaveen!

Is there a particular reason that you’re using the SplitInBacthes node? If the MySQL node returns different items then the subsequent node will execute for these different items.

For example, if the MySQL node returns similar to the following

[
  {
    "id":1,
    "email": "[email protected]"
  },
  {
    "id":2,
    "email": "[email protected]"
  }
]

The MySQL1 node will execute the query for both the outputs. Now based on the output of this node you can decide what should be the next step in the workflow. Let me know if this helps :slightly_smiling_face:

1 Like

Hey @harshil1712 Happy New Year Bro :partying_face: Thanks for your input.

I followed the different approach and Solved using WHERE NOT EXIST in MySQL Select query

Here it is:

SELECT email 
FROM   demo d 
WHERE  NOT EXISTS (
   SELECT email
   FROM   api_key
   WHERE  email = d.email
   );

Explanation:

It only shows the email address from table demo which is not present in the table api_key.

Then using the Split in Batches to sending an Email to all the batches