title: Mysql with express query returns null
body: <p>I use express on server side. 
  Here is the code:</p>
  
  <pre><code>// router
  const database = require('../services/database-service');
  
  router.get('/allreviews', function (req, res, next) {
      let reviewsSql =
          'select r.reviewId, r.username, r.time, r.reviewText, r.visit, ri.fileName ' +
          'from (select min(reviewImgId) as imgId, reviewId ' +
          'from ReviewImgs ' +
          'group by reviewId) img, Reviews r, ReviewImgs ri ' +
          'where img.imgId=ri.reviewImgId and ri.reviewId=r.reviewId;';
  
      database.query(reviewsSql, function (result) {
          console.log(result);   // NULL
          res.send(result);
      });
  });
  
  // database-service.js
  const mysql=require('mysql');
  
  module.exports = {
      query: function (sql, data, fn) {
          const connection = mysql.createConnection({
              host     : '127.0.0.1',
              user     : 'root',
              password : 'xxxxxxxxx',
              database : 'Movie',
              port:'3306'
          });
  
          connection.connect();
  
          connection.query(sql, data, function (error, result) {
              if (error){
                  console.log(error);
                  return;
              }
  
              fn(result);
          });
  
          connection.end();
      }
  };
  </code></pre>
  
  <p>The problem is that the query result is always null. However, I execute the sql query code in mysql command line, and the result is a set containing 3 rows, which is exactly what I want. So what's happening?</p>