AutomationFlowsData & Sheets › Automated Mysql to Google Sheets Sync with Duplicate Prevention

Automated Mysql to Google Sheets Sync with Duplicate Prevention

ByAhmed Saadawi @ahmedsaadawi on n8n.io

Description:

Cron / scheduled trigger★★★☆☆ complexity9 nodesMySQLGoogle Sheets
Data & Sheets Trigger: Cron / scheduled Nodes: 9 Complexity: ★★★☆☆ Added:

This workflow corresponds to n8n.io template #6261 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "TmP9EhlzHlU4r1wS",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Sync MySQL Rows to Google Sheet",
  "tags": [],
  "nodes": [
    {
      "id": "a78b4dc6-b4c6-4ed8-8b9f-dad0a6897307",
      "name": "Select rows from a table",
      "type": "n8n-nodes-base.mySql",
      "position": [
        -288,
        -112
      ],
      "parameters": {
        "table": {
          "value": "fifa25_customers"
        },
        "where": {
          "values": [
            {
              "value": "=0",
              "column": "sync"
            }
          ]
        },
        "options": {},
        "operation": "select"
      },
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "b1a1e46f-4d7f-4068-a697-e35735af7718",
      "name": "Append row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        352,
        -304
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "={{ $json.id }}",
            "name": "={{ $json.name }}",
            "email": "={{ $json.email }}",
            "phone": "={{ $json.phone }}",
            "gender": "={{ $json.gender }}",
            "region": "={{ $json.region }}",
            "datatime": "={{ $json.datatime }}",
            "birthdate": "={{ $json.birthdate }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "phone",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "birthdate",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "birthdate",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "region",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "region",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "gender",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "gender",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "datatime",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "datatime",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "value": "gid=0"
        },
        "documentId": {
          "value": "1b86B_7Hcusp7ehDNjJZtCa8Rlmljf2av7Hs-gaSluoc"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "e7f77e58-ddfc-4086-8016-6ebdd9d01d44",
      "name": "Update rows in a table",
      "type": "n8n-nodes-base.mySql",
      "position": [
        352,
        -128
      ],
      "parameters": {
        "table": {
          "value": "fifa25_customers"
        },
        "options": {},
        "dataMode": "defineBelow",
        "operation": "update",
        "valuesToSend": {
          "values": [
            {
              "value": "1",
              "column": "sync"
            }
          ]
        },
        "valueToMatchOn": "={{ $json.id }}",
        "columnToMatchOn": "id"
      },
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "0aba12f9-2627-4be1-bd53-1505d332f352",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -336,
        48
      ],
      "parameters": {
        "color": 3,
        "width": 208,
        "height": 80,
        "content": "Get 50 records from mysql table from not synced data"
      },
      "typeVersion": 1
    },
    {
      "id": "2ad57e58-7f42-4ef3-8d3a-228fc8ab422b",
      "name": "Schedule Trigger Every n Mins",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -528,
        -112
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b52eebd6-1177-414e-8062-1204ac643dc9",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        16
      ],
      "parameters": {
        "color": 3,
        "width": 208,
        "height": 80,
        "content": "Update all the got data with column sync = 1 to prevent duplication in next run"
      },
      "typeVersion": 1
    },
    {
      "id": "13a3b1e5-32b2-436f-9961-d924c9d052ef",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        352,
        160
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f82d841b-fbda-4eed-80e5-15fa83a6cc00",
      "name": "Check if new record returned",
      "type": "n8n-nodes-base.if",
      "position": [
        -80,
        -112
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fdc56e38-29be-42a1-baa8-3c4e2380b2c1",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $jmespath($input.all(), '[].json').length }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d35b54c0-1bde-43d8-ad95-e79c9a5b3957",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -352
      ],
      "parameters": {
        "width": 400,
        "height": 656,
        "content": "## Output"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "75f1c88c-35cb-4762-ba78-e19a2ca167bd",
  "connections": {
    "Select rows from a table": {
      "main": [
        [
          {
            "node": "Check if new record returned",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if new record returned": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          },
          {
            "node": "Update rows in a table",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger Every n Mins": {
      "main": [
        [
          {
            "node": "Select rows from a table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Description:

Source: https://n8n.io/workflows/6261/ — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

ProEx-ENG. Uses mySql, gmail, googleDrive, googleSheets. Scheduled trigger; 14 nodes.

MySQL, Gmail, Google Drive +3
Data & Sheets

Import Data From Mysql Into Google Sheets. Uses mySql, googleSheets. Scheduled trigger; 3 nodes.

MySQL, Google Sheets
Data & Sheets

Import Data From Google Sheets Into Mysql. Uses mySql, googleSheets. Scheduled trigger; 3 nodes.

MySQL, Google Sheets
Data & Sheets

This workflow queries a table in MySQL and inserts the data into Google Sheets.

MySQL, Google Sheets
Data & Sheets

This workflow imports data from Google Sheets into a MySQL database.

MySQL, Google Sheets