Mysql query "set" error

Hello,

In MYSQL I have a view that looks up a function in order to get the value to perform the search.

The following query works perfectly in any “Editor”:

set @device_id :=173;
Select
geofences.name,
geofences.google_destinations,
positions_limited.longitude,
positions_limited.latitude,
route_geo_seq.geo_seq
From
devices_routes Inner Join
route_geo_seq On route_geo_seq.bus_id = devices_routes.device_id Inner Join
routes_geofences On devices_routes.route_id = routes_geofences.route_id Inner Join
geofences On geofences.id = routes_geofences.geofence_id And
geofences.route_seq = route_geo_seq.geo_seq Inner Join
positions_limited On devices_routes.device_id = positions_limited.device_id
Limit 1;

However, in n8n i get the following:

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 'Select
      geofences.name,
      geofences.google_destinations,
      position' at line 2
    at PromiseConnection.query (/usr/local/lib/node_modules/n8n/node_modules/mysql2/promise.js:93:22)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/MySql/MySql.node.js:250:39
    at Array.map (<anonymous>)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/MySql/MySql.node.js:248:42)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:658:28)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:585:53

any ideas?

Thank you in advance

Could it be this?

(node.js - MySQL query variables in node - Stack Overflow)

My previous thought was correct…

https://community.n8n.io/t/multiple-queries-on-same-line-on-a-mysql-node-doesnt-work/6953

surely there must be a way of bypassing this??

Hi @xewonder - thanks for writing in about this, and for the link!

It doesn’t look like there’s a workaround for this, so I’ve moved this to our feature request section so our product team can get eyes on it :+1:

1 Like

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