title: SELECT not working in node.js
body: <p>I'm trying to use a SELECT query on my SQL database using node.js, the SELECT query below should work but doesn't. This is weird because I think this should work but it doesn't even enter the client.query function. I also copied my INSERT query which is actually working to show you my connection to the database works fine. </p>
  
  <p>What am I doing wrong in the SELECT query?</p>
  
  <p>CreateConnection</p>
  
  <pre><code>var mysql = require('mysql');
  var client = mysql.createConnection({
      host: '***',
      user: '***',
      password: '***',
      database: '***'
  });
  </code></pre>
  
  <p>SELECT Query (Not working)</p>
  
  <pre><code>    function query(sql){
        var returnvalue = "tempVal";
        client.connect();
        client.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
          returnvalue = "doens't even enter function";
          if (err) throw err;
  
          returnvalue = rows[0].solution;
        });
        client.end();    
        return returnvalue;
      }
  </code></pre>
  
  <p>INSERT Query (Is working)</p>
  
  <pre><code>function query(sql){
    client.connect();
    client.query('INSERT INTO users (username) VALUES("foo")');
    client.end();
  }
  </code></pre>