I'm trying to insert values using mysql in nodejs. I had written the following code and installed MySQL support via npm, But cannot INSERT INTO the table due to this problem.
My code;
create: (data, callBack) => {
pool.query(
`insert into position(title,group,level,payScale,totslPost) values(?,?,?,?,?)`,
[data.title, data.group, data.level, data.payScale, data.totalPost],
(err, result, fields) => {
if (err) {
return callBack(err);
}
return callBack(null, result);
}
);
},
error on Postman:
{
"success": false,
"message": "Couldn't create the position",
"error": {
"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 'position(title, group, level, payScale, totalPost) values('Jr. IT Consultant','C','L' at line 1",
"sql": "insert into position(title, group,level, payScale, totslPost) values('Jr. IT Consultant','C','L-1','18,000-56,900',33)"
}
}
Using api i'm trying to insert data into database