title: SQL join multiple values from column into one cell
body: <p>There are a ton of SQL <code>JOIN</code> questions already, but I didn't see my answer so here it goes.</p>
  <p>I am working with MySQL 5.0 and Wordpress Database using helper classes <a href="https://developer.wordpress.org/reference/classes/wpdb/" rel="nofollow noreferrer">wpdb</a> and <a href="https://github.com/ezSQL/ezsql" rel="nofollow noreferrer">ezsql</a>. Trying to achieve the 'simple' desired output below has not proven to be easy.</p>
  <p>Current output:</p>
  <pre><code>MemberID          MemberName              FruitName
  --------------    ---------------------   --------------
  1                  Al                     Apple
  1                  Al                     Cherry
  </code></pre>
  <p>Desired output:</p>
  <pre><code>MemberID           MemberName            FruitName
  -----------        --------------        ------------
  1                  Al                    Apple, Cherry
  </code></pre>
  <p><code>MemberID</code> comes from the table <code>a</code>, <code>MemberName</code> comes from the tables <code>a</code> and <code>b</code>, and <code>FruitName</code> comes from the table <code>b</code>. Because I am outputting a lot of other columns from the table <code>a</code>, I have 'left joined' the two tables through this query:</p>
  <pre><code>$contents = $wpdb-&gt;get_results( $wpdb-&gt;prepare(&quot;SELECT * FROM a LEFT JOIN b ON a.MemberName = b.MemberName&quot;));
  </code></pre>
  <p>I later print the columns using echo:</p>
  <pre><code>        &lt;td&gt;&lt;?php echo $content-&gt;MemberID ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $content-&gt;MemberName ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $content-&gt;FruitName ?&gt;&lt;/td&gt;
  </code></pre>
  <p>I assume I should try to query/join the two tables in a different manner though it may be possible to get creative in printing the columns. I found this <a href="http://www.eggheadcafe.com/conversation.aspx?messageid=34132286&amp;threadid=34132286" rel="nofollow noreferrer">discussion here</a> and modeled my question after it but I don't understand their solutions and am hoping for something simpler.</p>