title: How to change a value in MySQL Database to a value of a variable defined in JS/Node?
body: <p>In the database a customer has  unique id which is defined below as idEmail = id, I am trying to find the customer in the database against this id and then replace their hashed password but I'm struggling with the SQL syntax as I'm not sure how I can give the &quot;password&quot; &amp; &quot;emailId&quot; in the query a value rather than setting &quot;password&quot; to &quot;password&quot; where &quot;id&quot; = &quot;emailId&quot; and not the actual value of the emailId variable:</p>
  <pre><code>app.post(&quot;/reset_password/:id/:token&quot;, (req, res, next) =&gt; {
  const { id, token} = req.params;
  const idEmail = id;
  const {password, password2} = req.body;
  db.query(&quot;SELECT * FROM user WHERE id = ?&quot;, [idEmail], async (error, results) =&gt; {
  if (id != results[0].id) {
    res.send(&quot;Invalid id&quot; + id + results[0].id)
    return
  }
  
  const secret = JWT_SECRET + results[0].password
  try {
    const payload = jwt.verify(token, secret)
    if (password === password2) {
      let hashedPassword = await bcrypt.hash(password, 8);
      
      db.query(
        &quot;UPDATE user SET password = 'password' WHERE id = 'emailId' &quot;,
        {
          password: hashedPassword,
          emailId: idEmail,
        },
        (error, results) =&gt; {
          if (error) {
            console.log(error);
          } else {
  </code></pre>