title: Trying to combine resultset from two tables using key in MySQL
body: <p>I have two tables of data, <code>songs</code> and <code>files</code> in a MySQL database thus:</p>
  
  <p>Songs table:</p>
  
  <pre><code>  song_id   |   song_title    |
       1      |     A Title     |
       2      |     B Title     |
  </code></pre>
  
  <p>Files table:</p>
  
  <pre><code>  file_id   |    file_name    |  parent_id  |
      1       |    asong.mp3    |     1       |
      2       |    bsong.mp3    |     1       | 
  </code></pre>
  
  <p>I'd like to make one SQL query to return a set like this (where song_id = 1):</p>
  
  <pre><code>song_id =&gt; 1
  song_title =&gt; A Title
  song_files = Array(
       0 =&gt; Array(
              file_id =&gt; 1
              file_name =&gt; asong.mp3
            )
       1 =&gt; Array(
              file_id =&gt; 2
              file_name =&gt; bsong.mp3
            )
  )
  </code></pre>
  
  <p>Ideally, I only want to query the database once, and have been exploring JOINs, but I'm not convinced that is the method I need. I'm using PHP 5</p>
  
  <p>Many thanks!
  Olly</p>