title: Node Mysql async multiple queries
body: <p>I was wondering what's the best way to handle nested mysql-queries is nodejs. </p>
  
  <p>So something like this: </p>
  
  <pre><code>connection.query("SELECT * FROM blogs ORDER BY time DESC", function(err, blogs, fields) {
  
     for (blog in blogs) {
  
          connection.query("SELECT * FROM tags WHERE blog_id='blog.id' ", function(err, tags, fields) {
  
          blog.tags = tags
  
       });
  
     }
  
     res.send(blogs)
  
  });
  </code></pre>
  
  <p>This obviously doesn't work, because of the async nature. The result already gets returned before the tags are fetched.</p>
  
  <p>I've been reading up on node and callbacks and promises seems to be the way to go. But I'm unable to see how I would best use them in this small example. </p>
  
  <p>Thx!</p>