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.
Current output
MemberID MemberName FruitName
-------------- --------------------- --------------
1 Al Apple
1 Al Cherry
Desired output
MemberID MemberName FruitName
----------- -------------- ------------
1 Al Apple, Cherry
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:
$contents = $wpdb->get_results( $wpdb->prepare("SELECT * FROM a LEFT JOIN b ON a.MemberName = b.MemberName"));
I later print the columns using echo:
<td><?php echo $content->MemberID ?></td>
<td><?php echo $content->MemberName ?></td>
<td><?php echo $content->FruitName ?></td>
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 discussion here and modeled my question after it but I don't understand their solutions and am hoping for something simpler.