I have error when try to LEFT JOIN in MySQL node

I have error when try to LEFT JOIN in MySQL node

This is error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 2

Please share the workflow

{
  "nodes": [
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT keywords.keyword, keywords.traffic, keywords.keyword_group, keywords.keyword_id, negative.smart_id, negative.sheet FROM keywords, type, smart_map\nLEFT JOIN negative"
      },
      "name": "Get keyword1",
      "type": "n8n-nodes-base.mySql",
      "typeVersion": 1,
      "position": [
        420,
        550
      ],
      "alwaysOutputData": true,
      "credentials": {
        "mySql": {
          "id": "45",
          "name": "MySQL working24_keywords"
        }
      },
      "continueOnFail": true
    }
  ],
  "connections": {}
}

Share the output returned by the last node

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 2

Information on your n8n setup

  • n8n version: 0.149.0
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default)]:
  • Running n8n via [Docker]:

Hey @cmdntd987,

Does that query work if ran directly? Normally if I was doing a left join I would do a left join table on table.column = other_table.column Could be worth giving it a go.

Yes, I tried with “ON” or “USING” conditions
On above example, I use LEFT JOIN simply
It is failed with LEFT JOIN, RIGHT JOIN, LEFT OUTER JOIN, RIGHT OUTER JOIN…

But it is ok if I use INNER JOIN

That is odd, do you have access to the database server itself to see why it thinks the syntax is incorrect?

Its relationships is ok. But I am not sure about my syntax.
Could you check with your own mysql?

I could but I don’t have your database, I have been using it with the option I mentioned so I am not sure why it isn’t working for you.

The first place I would check if the query can be ran manually is in the MySQL log which will tell you a lot more.

I will try and mock up what I think your database looks like when I get near my computer, looking at the queue you are selecting values from 2 tables but in your from you have 3 tables what happens if you remove the 2 not being used?

1 Like

I could create a demo database for you for test
But how could I send private account info to you on this forum?

If you click on my profile image it should give you an option to send a direct message or an email to me.

Just the schema and some dummy data would be enough no need to set up a database instance I can just make a new one in my test environment here.

Well, when I try to create demo and run, it runs ok.
I think that is an issue in my data structure, I will test it

Thank you anyway.

1 Like

No problem :+1:

You know where to find me (or members of the n8n team / community) if you get stuck.

2 Likes