title: MySQL joining tables one-to-many relationship
body: <p>I am trying to achieve something in MySQL but even with all the answers here or on other sites, I still cannot accomplish the goal.</p>
  
  <p>I have two tables, in one-to-many relationship.</p>
  
  <pre><code>TABLE Files
  COLUMNS id, title, description, uploaded, size, extension, etc.
  
  TABLE Files_Meta
  COLUMNS id, parent_id, key, value
  </code></pre>
  
  <p>Obviously each file has multiple meta data represented as many rows in the <strong>Files_Meta</strong> table. For example <strong>File1</strong> has meta Author, Place, Time, Tags, Camera -- if it's a photo.</p>
  
  <p>I'm trying to select all rows from <strong>Files</strong> table including meta data.</p>
  
  <h3>Standard result</h3>
  
  <pre><code>stdClass Object
  (
  [id] =&gt; 10
  [title] =&gt; Hello world
  [size] =&gt; 745198
  [extension] =&gt; jpg
  [user_id] =&gt; 0
  [category_id] =&gt; 0
  [date_uploaded] =&gt; 2012-06-08 13:37:55
  [description] =&gt; 
  [downloaded] =&gt; 0
  [viewed] =&gt; 8
  )
  
  stdClass Object
  (
  [id] =&gt; 90
  [parent_id] =&gt; 10
  [key] =&gt; place
  [value] =&gt; New York
  )
  </code></pre>
  
  <h3>What I want</h3>
  
  <pre><code>stdClass Object
  (
  [id] =&gt; 10
  [title] =&gt; Hello world
  [size] =&gt; 745198
  [extension] =&gt; jpg
  [user_id] =&gt; 0
  [category_id] =&gt; 0
  [date_uploaded] =&gt; 2012-06-08 13:37:55
  [description] =&gt; 
  [downloaded] =&gt; 0
  [viewed] =&gt; 8
  [meta] =&gt; Array (
      place =&gt; New York
      author =&gt; John Doe
      time =&gt; March 2001
      camera =&gt; Canon EOS
      etc.
      )
  )
  </code></pre>
  
  <p>Is it possible to achieve this in MySQL? Doesn't have to look like this, without that array.</p>
  
  <pre><code>stdClass Object
  (
  [id] =&gt; 10
  .
  .
  [place] =&gt; New York
  [author] =&gt; John Doe
  [time] =&gt; March 2001
  [camera] =&gt; Canon EOS
  )
  </code></pre>
  
  <p>Thanks in advance for replies or tips.</p>