title: Data deletion from database dynamically using delete request in node.js
body: <p>I am using normal http request for deleting value from mysql database using node.js. But right now, only values are deleted statically not dynamically. I want to delete the data dynamically by providing the id.</p>
  
  <pre><code>const server = http.createServer();
  const reqUrl = url.parse(req.url, true);
  
  server.on('request', (req, res) =&gt; {
    if (reqUrl.pathname === '/delete'){
  
     req.on('end', () =&gt; {                        
         let sql = "Delete from students where id=12";     
          connection.query(sql, function (err, result) {
           if (err) throw err;
          console.log(result);
          });
          })
      res.end();   
     }
  });
  </code></pre>
  
  <p>now, after running this code <a href="http://www.example.com/" rel="nofollow noreferrer">localhost:3000/delete</a>  only the id=12 is deleted all time. But I want to do this  <a href="http://www.example.com/" rel="nofollow noreferrer">localhost:3000/delete?id=12</a> giving input values as id.</p>
  
  <p>I tried to give sql command as <strong>"Delete from students where id=?"</strong> , but it gave errors. How can I solve this?</p>