MySQL pulling content from 2 tables that is connected by a third table
<p>I currently have 2 tables in a database I need to get information from, "content" and "type".  These two tables are linked by a 3rd table name "typeMembers."  This is the structure:</p>

<pre><code>Table Content:
id      content      link      date    isPublished
1       content 1    link 1    3/13/91  1
2       content 2    link 2    3/18/91  1
3       content 3    link 3    3/22/91  1

Table type:
id    name
1     Event
2     Page
3     Test

Table typeMember
id    type_id    content_id
1     1          1
2     2          1
3     3          1
4     1          2
5     1          3
</code></pre>

<p>Currently I have my query set up as:</p>

<pre><code>//using PDO in PHP
q = $dbc-&gt;prepare(
    "SELECT a.id, a.content,a.date,a.link, c.name 
     FROM content a 
     LEFT OUTER JOIN typeMember b 
     ON b.content_id = a.id 
     LEFT OUTER JOIN types c 
     ON b.type_id = c.id  
     WHERE a.isPublished = 1 
     ORDER BY a.date DESC"
   );
$r = $q-&gt;execute();
</code></pre>

<p>When this is returned I am getting 1 row for each typeMember in the database instead of content.  What am I structuring wrong?</p>

<p>Data I would like to be returned:</p>

<pre><code>id      content      link      date      name
1       content 1    link 1    3/13/91   Event, Page, Test
2       content 2    link 2    3/18/91   Event
3       content 3    link 3    3/22/91   Event
</code></pre>

<p>How it is being returned</p>

<pre><code>id      content      link      date      name
1       content 1    link 1    3/13/91   Event
1       content 1    link 1    3/13/91   Page
1       content 1    link 1    3/13/91   Test
2       content 2    link 2    3/18/91   Event
3       content 3    link 3    3/22/91   Event
</code></pre>

<p>Edit: filing out the data actually made me realize what is going on.  There is a 1 to many relationship with content to type.  Is there a way to get all the types in one query?</p>