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

399
Visualizações
getting mysql syntax error while using parameters in mysql query

Getting sql syntax error in nodejs

Am using this code :

async function getNotificationFsql(data) {
    var query = "select * from notifications where id>${data.start} and receiver=${data.recId} limit 10";
    var record = await db.sequelize.query(query ,
        function (err,results) {
            if (err) {
                console.log('Error while getting data from MYSQL     :-   ' + err);
            } else {
                console.log('Notifications data which we got from MYSQL     :-   ' + results);
            }
        }
    );
    // console.log(record);
    console.log('Notifications      :-   ' + record[0]);
    return record[0];
};

And I got:

code: 'ER_PARSE_ERROR', errno: 1064, sqlState: '42000',

sqlMessage: "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 '{data.start} and receiver=${data.recId} limit 10' at line 1",

sql: 'select * from notifications where id>${data.start} and receiver=${data.recId} limit 10', parameters: undefined }, sql: 'select * from notifications where id>${data.start} and receiver=${data.recId} limit 10', parameters: undefined

What am I doing wrong?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

sorry, am doing this wrong

i solve this error doing this :

var query = "select * from notifications where id>"+data.start+" and receiver="+data.recId+" limit 10";
about 4 years ago · Juan Pablo Isaza Relatório
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