Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL join multiple values from column into one cell
    primarykey
    data
    text
    <p>There are a ton of sql join q's already but I didn't see my answer so here goes . . . I am working with WPDB (Wordpress database)/EZSql/MySQL 5.0. 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>MemberID comes from table a, MemberName comes from table a and table b, and FruitName comes from table b. Because I am outputting a lot of other columns from table a, I have 'left joined' the two tables through this query:</p> <pre><code>$contents = $wpdb-&gt;get_results( $wpdb-&gt;prepare("SELECT * FROM a LEFT JOIN b ON a.MemberName = b.MemberName")); </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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload