title: How to do multiple mysql queries in one line in Node.js
body: <p>I'm trying to get results from multiple tables with one request from client. I first tried JOIN, but that would mean I'd have to have multiple rows that contain duplicate information. Then I decided to do a different query for each table separately, although I'm not sure know how cost efficient this is.</p>
  
  <p>How should I construct the query so that it is accepted by Node.js? The one I'm trying to use now doesn't work if I don't use quotation marks to wrap the whole query, but if I do use them it complains there is an error with my query.</p>
  
  <p>Here is the code for the query.</p>
  
  <pre><code>sql = "'SELECT * from `Ilmoittautuminen` WHERE `optunnus` LIKE ' + mysql.escape(reg.body.optunnus); 'SELECT * from `Jasenmaksu` WHERE `optunnus` LIKE ' + mysql.escape(reg.body.optunnus); 'SELECT * from `OppOikeus` WHERE `optunnus` LIKE ' + mysql.escape(reg.body.optunnus);"
  console.log(sql);
  connection.query(sql, function(err, rows){
      console.log(rows)
      if(err){
          console.log(err)
          res.json({
              success: false,
              message: err,
          });
      }else{
           queryResponse(res, rows);
      }
  });
  </code></pre>