Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

428
Visualizações
Error in your SQL syntax SET Syntax, how to solve?

While on the Lambda function, I'm trying to run the query below, 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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda