Here is my usecase:
- Cron Job run every x days. It select all the email address from the database. (I’ll replace start node with cronjob)
- Then SplitinBatches Node split all the data into batches. (Currently Batch size is 1)
- Then goes into Another MySQL Node(Number 3) (Checking for that email got from MySQL Node (Number 1) inside different table)
- 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
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
380,
300
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT email FROM demo;"
},
"name": "MySQL",
"type": "n8n-nodes-base.mySql",
"typeVersion": 1,
"position": [
550,
300
],
"credentials": {
"mySql": "Singapore DB"
}
},
{
"parameters": {
"batchSize": 1,
"options": {}
},
"name": "SplitInBatches",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 1,
"position": [
700,
300
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "=SELECT email from api_key WHERE email='{{$node[\"SplitInBatches\"].json[\"email\"]}}';"
},
"name": "MySQL1",
"type": "n8n-nodes-base.mySql",
"typeVersion": 1,
"position": [
850,
300
],
"credentials": {
"mySql": "Singapore DB"
}
},
{
"parameters": {
"fromEmail": "[email protected]",
"toEmail": "={{$node[\"SplitInBatches1\"].json[\"email\"]}}",
"subject": "Hi",
"text": "How are you?",
"options": {}
},
"name": "Send Email",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 1,
"position": [
1170,
380
],
"credentials": {
"smtp": "SendGrid 1"
}
},
{
"parameters": {
"batchSize": 1,
"options": {
"reset": false
}
},
"name": "SplitInBatches1",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 1,
"position": [
1000,
310
]
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "MySQL",
"type": "main",
"index": 0
}
]
]
},
"MySQL": {
"main": [
[
{
"node": "SplitInBatches",
"type": "main",
"index": 0
}
]
]
},
"SplitInBatches": {
"main": [
[
{
"node": "MySQL1",
"type": "main",
"index": 0
}
]
]
},
"MySQL1": {
"main": [
[
{
"node": "SplitInBatches1",
"type": "main",
"index": 0
}
]
]
},
"Send Email": {
"main": [
[
{
"node": "SplitInBatches",
"type": "main",
"index": 0
}
]
]
},
"SplitInBatches1": {
"main": [
[
{
"node": "Send Email",
"type": "main",
"index": 0
}
]
]
}
}
}