# MySQL node | Query parameter bugged

**URL:** <https://community.n8n.io/t/mysql-node-query-parameter-bugged/167949>\
**Category:** Questions\
**Created:** [August 14, 2025, 6:19pm UTC](https://community.n8n.io/t/mysql-node-query-parameter-bugged/167949 "2025-08-14T18:19:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Azura](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/azura/32/110016_2.png) [@Azura](https://community.n8n.io/u/Azura)\
**Post date:** [August 14, 2025, 6:19pm UTC](https://community.n8n.io/t/mysql-node-query-parameter-bugged/167949/1 "2025-08-14T18:19:07Z")

</div>

## Describe the problem/error/question

I’m trying to use query parameters within my MySQL node called **“Upsert lead”**.  
However, it seems that the **“Query Parameters”** setting has some bugs:

- `null` values are being converted to `''` (empty strings) in the output query instead of staying as `null`, even when the **“Replace Empty Strings with NULL”** option is enabled.  
In fact, this setting doesn’t seem to work at all.

- Fields appear to shift positions when there are empty fields in between.

- If none of the fields are `null` or empty, everything works as expected.

## What is the error message (if any)?

```sql
INSERT INTO ld_leads (
    email,
    campaign_id,
    first_name,
    last_name,
    company_id,
    job_title
) VALUES (
    'email@example.com',
    1,
    1,
    '',
    '',
    ''
)
ON DUPLICATE KEY UPDATE
    campaign_id = IFNULL(NULLIF('', ''), campaign_id),
    first_name = IFNULL(1, first_name),
    last_name = IFNULL(1, last_name),
    company_id = IFNULL(NULLIF('', ''), company_id),
    job_title = IFNULL(NULLIF('', ''), job_title);

```

## Please share your workflow

```json
{
  "nodes": [
    {
      "parameters": {
        "operation": "executeQuery",
        "query": ,
        "options": {
          "queryReplacement": 
          "replaceEmptyStrings": true
        }
      },
      "type": "n8n-nodes-base.mySql",
      "typeVersion": 2.5,
      "position": [
        448,
        -48
      ],
      "id": "b0d880ea-86f8-478e-8748-2cbbc4491990",
      "name": "Upsert lead",
      "credentials": {
        "mySql": {
          "id": "1jPH9m4KLMjZ6Qnk",
          "name": "MySQL | atspub_dev"
        }
      }
    },
    {
      "parameters": {
        "operation": "select",
        "table": {
          "__rl": true,
          "value": "ld_leads",
          "mode": "list",
          "cachedResultName": "ld_leads"
        },
        "returnAll": true,
        "where": {
          "values": [
            {
              "column": "email",
              "value": "={{ $('Sub-Flow Trigger').item.json.email }}"
            }
          ]
        },
        "options": {
          "detailedOutput": false
        }
      },
      "type": "n8n-nodes-base.mySql",
      "typeVersion": 2.5,
      "position": [
        672,
        -144
      ],
      "id": "3b4c902f-a22c-4fd8-b1f3-d2123015a864",
      "name": "Return row",
      "credentials": {
        "mySql": {
          "id": "1jPH9m4KLMjZ6Qnk",
          "name": "MySQL | atspub_dev"
        }
      }
    },
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "update_empty_fields",
              "type": "boolean"
            },
            {
              "name": "campaign_id",
              "type": "number"
            },
            {
              "name": "email"
            },
            {
              "name": "first_name"
            },
            {
              "name": "last_name"
            },
            {
              "name": "company_id",
              "type": "number"
            },
            {
              "name": "job_title"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        -144
      ],
      "id": "7a931d60-b697-4988-806f-2f77b3342615",
      "name": "Sub-Flow Trigger"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "5d9f9cd1-20e2-4f1e-85a3-f9b00c0f8cba",
              "leftValue": "={{ $json.update_empty_fields }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        224,
        -144
      ],
      "id": "a348f793-b116-4175-9c86-826dd0a788ba",
      "name": "Update empty fields?"
    },
    {
      "parameters": {
        "operation": "upsert",
        "table": {
          "__rl": true,
          "value": "ld_leads",
          "mode": "list",
          "cachedResultName": "ld_leads"
        },
        "dataMode": "defineBelow",
        "columnToMatchOn": "email",
        "valueToMatchOn": "={{ $json.email }}",
        "valuesToSend": {
          "values": [
            {
              "column": "campaign_id",
              "value": "={{ $json.campaign_id }}"
            },
            {
              "column": "first_name",
              "value": "={{ $json.first_name }}"
            },
            {
              "column": "last_name",
              "value": "={{ $json.last_name }}"
            },
            {
              "column": "company_id",
              "value": "={{ $json.company_id }}"
            },
            {
              "column": "job_title",
              "value": "={{ $json.job_title }}"
            }
          ]
        },
        "options": {
          "replaceEmptyStrings": true
        }
      },
      "type": "n8n-nodes-base.mySql",
      "typeVersion": 2.5,
      "position": [
        448,
        -240
      ],
      "id": "49ef0397-5de5-42a5-8aa7-7bd5c4a5278e",
      "name": "Upsert lead | Update empty fields",
      "credentials": {
        "mySql": {
          "id": "1jPH9m4KLMjZ6Qnk",
          "name": "MySQL | atspub_dev"
        }
      }
    }
  ],
  "connections": {
    "Upsert lead": {
      "main": [
        [
          {
            "node": "Return row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Return row": {
      "main": [
        []
      ]
    },
    "Sub-Flow Trigger": {
      "main": [
        [
          {
            "node": "Update empty fields?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update empty fields?": {
      "main": [
        [
          {
            "node": "Upsert lead | Update empty fields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Upsert lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert lead | Update empty fields": {
      "main": [
        [
          {
            "node": "Return row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {
    "Sub-Flow Trigger": [
      {
        "update_empty_fields": false,
        "campaign_id": 1,
        "email": "email@example.com",
        "first_name": "",
        "last_name": "",
        "company_id": 1,
        "job_title": ""
      }
    ]
  },
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "642fefb0ab25e779a8a9e8ccbe2dd6f06e6f7878da88ff09da8e1f54695ffea6"
  }
}

```

## Share the output returned by the last node

```sql
INSERT INTO ld_leads (
    email,
    campaign_id,
    first_name,
    last_name,
    company_id,
    job_title
) VALUES (
    'email@example.com',
    1,
    1,
    '',
    '',
    ''
)
ON DUPLICATE KEY UPDATE
    campaign_id = IFNULL(NULLIF('', ''), campaign_id),
    first_name = IFNULL(1, first_name),
    last_name = IFNULL(1, last_name),
    company_id = IFNULL(NULLIF('', ''), company_id),
    job_title = IFNULL(NULLIF('', ''), job_title);

```

## Information on your n8n setup

- **n8n version:** 1.105.4
- **Database (default: SQLite): Default**
- **n8n EXECUTIONS\_PROCESS setting (default: own, main): No idea what this is**
- **Running n8n via (Docker, npm, n8n cloud, desktop app): Docker**
- **Operating system: Ubuntu 22.04**

---

<div class="post-metadata">

**Author:** ![Azura](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/azura/32/110016_2.png) [@Azura](https://community.n8n.io/u/Azura)\
**Post date:** [August 14, 2025, 6:35pm UTC](https://community.n8n.io/t/mysql-node-query-parameter-bugged/167949/2 "2025-08-14T18:35:55Z")

</div>

**VERY IMPORTANT NOTE!!!**

I think i found the problems!

- ‘‘ doesnt translate to null even if you enable the setting for that!
- You can’t use a parameter twice in your query. So if you have $1 and $2, you cannot use them again otherwise it will bug. Put the values twice in parameter query and use $3 and $4 and it will work

---

<div class="post-metadata">

**Author:** ![Azura](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/azura/32/110016_2.png) [@Azura](https://community.n8n.io/u/Azura)\
**Post date:** [August 17, 2025, 11:36pm UTC](https://community.n8n.io/t/mysql-node-query-parameter-bugged/167949/3 "2025-08-17T23:36:19Z")

</div>

Another bug found with query parameters. comma breaks them.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [November 15, 2025, 11:37pm UTC](https://community.n8n.io/t/mysql-node-query-parameter-bugged/167949/4 "2025-11-15T23:37:03Z")

</div>

Closed on November 15, 2025, 11:37pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
