I am attempting to retrieve the tags of every blog publish in a single SQL query. I've got a posts table, post_tags table along with a tags table. The post_tags table is available to get rid of the numerous-to-many relationship between posts and tags. Here's the schema for individuals tables:

| p_id | c_id | u_id |   title   |     body    |      published      |
----------------------------------------------------------------------
|  1   |  1   |   1  | first post| lorem ipsum | 2012-01-27 18:37:47 |


| p_id | t_id |
---------------
|  1   |  3   |


| t_id |     name    |     slug    |
------------------------------------
|  3   | programming | programming |

And also the PHP method I am using:

public function getLatestPosts()
{
    $query = $this->db->query('SELECT title, clean_title, body, published, name, slug
                               FROM posts
                               LEFT JOIN post_tags ON posts.p_id=post_tags.p_id
                               LEFT JOIN tags ON post_tags.t_id=tags.t_id
                               ORDER BY published DESC');
    $posts = array();
    foreach ($query->result() as $row)
    {
        $posts[] = array('title' => $row->title,
                             'clean_title' => $row->clean_title,
                             'body' => $row->body,
                             'published' => $row->published,
                             'tags' => array('name' => $row->name,
                                             'slug' => $row->slug));
    }
    print_r($posts);
    return $posts;
}

It kinda works, the posts tags are now being retrieved for every publish, however i have duplicate posts. Here is a print_r dump from the outcomes of the query:

Array
(
    [0] => Array
        (
            [title] => Second blog post, this is a pretty long title
            [clean_title] => second-blog-post-this-is-a-pretty-long-title
            [body] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus eget est sit amet libero volutpat eleifend facilisis sollicitudin nisl. Nulla elit eros, semper eget tincidunt quis, egestas a nisl. Duis tempor tempus sapien consequat pellentesque. Cras vitae orci risus. Duis urna velit, interdum ac consectetur nec, condimentum non tellus. Sed nec nibh nisi. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras purus nulla, tincidunt quis placerat a, interdum at turpis. Pellentesque in lectus lacus. Sed at venenatis neque.
            [published] => 2012-01-27 20:15:52
            [tags] => Array
                (
                    [name] => 
                    [slug] => 
                )

        )

    [1] => Array
        (
            [title] => This is my first post!
            [clean_title] => this-is-my-first-post
            [body] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus eget est sit amet libero volutpat eleifend facilisis sollicitudin nisl. Nulla elit eros, semper eget tincidunt quis, egestas a nisl. Duis tempor tempus sapien consequat pellentesque. Cras vitae orci risus. Duis urna velit, interdum ac consectetur nec, condimentum non tellus. Sed nec nibh nisi. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras purus nulla, tincidunt quis placerat a, interdum at turpis. Pellentesque in lectus lacus. Sed at venenatis neque.
            [published] => 2012-01-27 18:37:47
            [tags] => Array
                (
                    [name] => programming
                    [slug] => programming
                )

        )

    [2] => Array
        (
            [title] => This is my first post!
            [clean_title] => this-is-my-first-post
            [body] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus eget est sit amet libero volutpat eleifend facilisis sollicitudin nisl. Nulla elit eros, semper eget tincidunt quis, egestas a nisl. Duis tempor tempus sapien consequat pellentesque. Cras vitae orci risus. Duis urna velit, interdum ac consectetur nec, condimentum non tellus. Sed nec nibh nisi. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras purus nulla, tincidunt quis placerat a, interdum at turpis. Pellentesque in lectus lacus. Sed at venenatis neque.
            [published] => 2012-01-27 18:37:47
            [tags] => Array
                (
                    [name] => android
                    [slug] => android
                )

        )

    [3] => Array
        (
            [title] => This is my first post!
            [clean_title] => this-is-my-first-post
            [body] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus eget est sit amet libero volutpat eleifend facilisis sollicitudin nisl. Nulla elit eros, semper eget tincidunt quis, egestas a nisl. Duis tempor tempus sapien consequat pellentesque. Cras vitae orci risus. Duis urna velit, interdum ac consectetur nec, condimentum non tellus. Sed nec nibh nisi. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras purus nulla, tincidunt quis placerat a, interdum at turpis. Pellentesque in lectus lacus. Sed at venenatis neque.
            [published] => 2012-01-27 18:37:47
            [tags] => Array
                (
                    [name] => windows
                    [slug] => windows
                )

        )

)

When I view it, rather than coming back each tag for that publish, it's coming back several of this publish simply with different tags. I want it to ensure that the tags array for every publish comes with an element for every tag of this publish.

Any assistance is greatly appreciated :)