title: NODEJS node-mysql cannot pass query results in nested queries
body: <p>I am using node, angular and mysql, the node routes would return a json that would be processed by angular, the json is returned by first querying the mysql DB using the node-mysql module,
  In the below code I am unable to set the value of <code>CreatedID</code>, but the value gets logged properly in terminal. I was facing the same issue in the 1st query but then sorted it in the below code, now unable to access the nested query results. </p>
  
  <pre><code>           var mysql =  require('node-mysql/node_modules/mysql');
  
   var connection =  mysql.createConnection({
      host : 'localhost',
      user : "root",
      password: "",
      database:'designtaskmanager'
    });
   connection.connect();
  var allDbCalls = function() {
     var sendData = {};
     var rowData = {};
     var temp={};
     var _this = this;
     this.sendTask = function(callback) {
       module.exports.taskData =  rowData;
       callback['success']();
    };
  
  
  
    this.getTask = function(callback) {
      var strQuery = "select * from  task"; 
      connection.query( strQuery, function(err, rows){
        if(err) 
        {
          callback['failure']();
          throw err;
        }
        else
        {
          //rowData = rows;
          var tasks=[];
  
          for (var i in rows) 
          {
              var Title = rows[i].task_title;
              var TaskDescription=rows[i].task_description;
              var TaskCategory=rows[i].task_category;
              var TaskID=rows[i].task_id;
              var TaskStatus=rows[i].task_status;
              var TaskStatusMessage
              var CreatedBy;
              var TaskCreationDate=rows[i].task_creation_date;
              var _MS_PER_DAY = 1000 * 60 * 60 * 24;
  
  
  
              var currentdate = new Date(); 
  
              var ddd=dateDiffInDays(TaskCreationDate,currentdate);
  
              function dateDiffInDays(a, b) {
                // Discard the time and time-zone information.
                var utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
                var utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());
  
                return Math.floor((utc2 - utc1) / _MS_PER_DAY);
              }
  
              if(TaskStatus==0)
              {
                TaskStatus="label-info";
                TaskStatusMessage="Ongoing since";
  
              }
              else if(TaskStatus==1)
              {
                TaskStatus="label-default";
                TaskStatusMessage="Paused since"
  
              } 
              else if(TaskStatus==2)
              {
                TaskStatus="label-success";
                TaskStatusMessage="Completed in"
  
              }
  
              //USER DETAILS QUERY
              var crid=rows[i].task_created_by;
              var creatorQuery = "select user_email from  users where user_id like ?";
  
              connection.query( creatorQuery,[crid], function(err, createdbyrows){
                if(err) 
                {
                  callback['failure']();
                  throw err;
                }
                else
                {
                  for(var j=0; j&lt; createdbyrows.length;j++)
                  {
                    CreatedBy=createdbyrows[0].user_email;
                    console.log(j);
  
  
                  }
  
                    console.log(CreatedBy);
  
                }
            });
  
  
              var taskItem={"TaskID":TaskID,"TaskTitle":Title,"TaskDescription":TaskDescription,"TaskCategory":TaskCategory,"CreatedBy":CreatedBy,"TaskStatus":TaskStatus,"TaskStatusMessage":TaskStatusMessage,"DifferenceInDays":ddd};
  
            tasks.push(taskItem);
  
          }
  
            rowData=tasks;
             _this.sendTask(callback);   
        }
      });
    }
  
  }
  module.exports = function () {
    var instance = new allDbCalls();
    return instance;
  };
  </code></pre>