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?