title: How to properly return a result from mysql with Node?
body: <p>In the code</p>
  
  <pre><code>var stuff_i_want = '';
  stuff_i_want = get_info(parm);
  </code></pre>
  
  <p>And the function get_info:</p>
  
  <pre><code>get_info(data){
        var sql = "SELECT a from b where info = data"
        connection.query(sql, function(err, results){
              if (err){ 
                throw err;
              }
              console.log(results[0].objid); // good
              stuff_i_want = results[0].objid;  // Scope is larger than function
              console.log(stuff_i_want); // Yep. Value assigned..
      }
  </code></pre>
  
  <p>in the larger scope </p>
  
  <pre><code>stuff_i_want = null
  </code></pre>
  
  <p>What am i missing regarding returning mysql data and assigning it to a variable?</p>
  
  <p>============ New code per Alex suggestion</p>
  
  <pre><code>var parent_id = '';
      get_info(data, cb){
            var sql = "SELECT a from b where info = data"
            connection.query(sql, function(err, results){
                  if (err){ 
                    throw err;
                  }
                  return cb(results[0].objid);  // Scope is larger than function
      }
  </code></pre>
  
  <p>==== New Code in Use</p>
  
  <pre><code> get_data(parent_recording, function(result){ 
      parent_id = result;
      console.log("Parent ID: " + parent_id); // Data is delivered
    });
  </code></pre>
  
  <p>However</p>
  
  <pre><code>console.log("Parent ID: " + parent_id);
  </code></pre>
  
  <p>In the scope outside the function parent_id is null</p>