title: MySQL select row and join to multiple records
body: <p>I have 2 Tables and can't get my MySQL Query to work:</p>
  
  <pre><code>First Table users:
  user_id name
  ------------
  1       Bob
  2       Alice
  
  Second Table fields:
  id unser_id field_id value
  -----------------------------
  1  1        4           foo
  2  1        5           10
  3  2        4           bar
  </code></pre>
  
  <p>Now I would like to join the Tables in a way that outputs:</p>
  
  <pre><code>[0] =&gt; (
            [user_id] =&gt; 1
            [name] =&gt; Bob
            [fields] =&gt; (
                           [4] =&gt; foo
                           [5] =&gt; 10
                        )
  [1] =&gt; (
            [user_id] =&gt; 2
            [name] =&gt; Alice
            [fields] =&gt; (
                           [4] =&gt; bar
                        )
         )
  </code></pre>
  
  <p>Thanks a lot!</p>
  
  <p>I tried:</p>
  
  <pre><code>SELECT u.user_id, 
         u.name 
  FROM   users as u 
  INNER JOIN fields as f on u.user_id = d.user_id
  </code></pre>
  
  <p>But I get for every user just the first fields entry.</p>