Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

356
Views
Error in your SQL syntax: SET Syntax (Lambda function)

While on the Lambda function, I'm trying to run the following query, but it throws an ER_PARSE_ERROR error.

{

"errorType": "Error",

"errorMessage": "ER_PARSE_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 DISTINCT A.j FROM ...' at line 1",

"trace": [

const vandium = require('vandium');

var mysql = require('mysql');
var connection = mysql.createConnection({ multipleStatements: true });

exports.handler = vandium.generic()
    .handler((event, context, callback) => {

        var connection = mysql.createConnection({
            host: 'xjxj',
            user: 'xjxj',
            password: 'xjxj',
            database: 'xjxj'
        });
        var x = connection.escape(event.x);
        var y= connection.escape(event.y);
        var z = connection.escape(event.z);
  connection.query("SET @"+y+"=2; SELECT DISTINCT A.j FROM A INNER JOIN B, C WHERE A.j = B.j and C.x= " + x + " and C.y="+y+"  and C.z= " + z + "", function (error, results, fields) {
            if (error) {
                connection.destroy();
                throw error;
            }
            else {
                console.log(results);
                callback(null, results);
            }
        });
    });

I also thought of something like: ... "SET @y=2;..." but negative

I'm trying to implement something on similar lines:

SET @y := @k :=79;SELECT DISTINCT A.j FROM A INNER JOIN B, C WHERE A.j = B.j and C.x= " + x + " and C.y="+y+"  and C.z= " + z + "

Of course, there's no k in the first code block, but here's the rough idea.

What went wrong?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your code seems wrong you are mixing implicit join based tablename separated by comma and where condition and explicit join based on JOIN and ON clause and you are referring to a table name something non included in your query..

You should use a proper, explicit join clause and use proper tablename for column

"SELECT DISTINCT A.j 
FROM A
INNER JOIN B on A.j = B.j
INNER JOIN C ON c.X= " + x +" and c.y = " +y + " and c.z="+z+";
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!