This is my code.
pool.getConnection(function (err, connection) {
connection.query("delete from userFiles where type = 1 and
typeId = " + taskId + " and fileName
NOT IN ('?') ",[oldFileNames], function (err, rows) {
});
});
Now the problem is , node js is generating query like this,
delete from table_name where type = 1 and typeId = 1 and
fileName NOT IN (\'\'upload_149f2b78e5fd4096781bb5b8719b874f.png,upload_e8185e896cb0f8bb0b66d807cc60922c.png\'\')
I even tried like this,
connection.query("delete from userFiles where type = 1 and typeId = " + taskId + " and
fileName NOT IN ('" + oldFileNames + "') ",
function (err, rows) {
This generated query like this,
delete from userFiles where type = 1 and typeId = 1 and
fileName NOT IN (\'upload_149f2b78e5fd4096781bb5b8719b874f.png,
upload_e8185e896cb0f8bb0b66d807cc60922c.png\')
Both are causing mysql syntax error for the query(slashes are getting appended).
Can you suggest, what i can do to get rid of this error.