title: Join tables with comma values
body: <p>I have a hard nut to crack with joing 3 tables.
  I have a newsletter_items, newsletter_fields and newsletter_mailgroups which I want to be joined to get a list of newsletters.</p>
  
  <p>The newsletter_items contains the fields: </p>
  
  <pre><code>letter_id, letter_date, receivers, template, status
  
  That can look like
  
      1, 1234567899, 1,2 (comma separated), standard.html, 1
  </code></pre>
  
  <p>newsletter_fields contains the fields:</p>
  
  <pre><code>    field_uid, field_name, field_content, field_letter_uid
  
  That can look like 
  
      1, letter_headline, A great headline, 1
  </code></pre>
  
  <p>where field_letter_uid is the newsletter for which the field belongs to.</p>
  
  <p>and newsletter_mailgroups contains the fields:</p>
  
  <pre><code>mailgroup_id, mailgroup_name, number_of_members
  
  That can look like 
  
          1, Group1, 233
          2, Group2, 124
          3, Group3, 54
  </code></pre>
  
  <p>What I want is to combine these 3 tables to that I can get a list of all the newsletter like this:</p>
  
  <pre><code>Letter date | Letter headline | Receivers | Status
  
  2008-01-01 12:00:00 | A great headline | Group1, Group 2 | 1
  </code></pre>
  
  <p>So in short I want my SQL query to join the 3 tables and in that process select the receivers from the mailgroup table and display them comma separated like Group1, Group 2</p>
  
  <p>This what I got now</p>
  
  <pre><code>SELECT A.*, B.* FROM newsletter_items A, newsletter_fields B, WHERE B.field_letter_uid = A.letter_id AND field_name = 'letter_headline' AND A.template = '". $template ."'; 
  </code></pre>
  
  <p>But I can't seem to figure out how to get the mailgroups into that.</p>