Okay, I got a sql query here, and I want to put a dynamic value in userID but when I put this query with another query, It seems like the whole sql query doesn't work. I think It has some problem with template string but no clue why It's not working.
query that I'm trying to use
insert into CREDIT values (uuid(), userID, null, now(), now(), 3.00, 'C', now(), now(), null, null);
actual js code
let query = "UPDATE USER SET STATUS = 'C' WHERE CONFIRM_KEY = " + ${mysql.escape(req.params.id)}
query += `INSERT INTO CREDIT VALUES (uuid(), ${req.params.id}, null, now(), now(), 3.00, 'C', now(), now(), null, null)`
let result = await pool.query(query)
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 \'INSERT INTO CREDIT VALUES (uuid(), \'66915b91-f9f7-11e7-8ffe-8785394e9837\', null,\' at line 1' }
WHERE CONFIRM_KEY = " + "'" + {mysql.escape(req.params.id)} + "'"?