I'm trying to get the "subposts" of a post MySql

Viewed 9

In my “posts” data table I have “id” and “parent_id”

I’m trying assign the parent_id to id, so I can get a subposts of a post.

This is what I have:

public function get_subposts()
{
    $query = $this->db->query("SELECT * FROM posts WHERE posts.parent_id != 0");
    return $query->result();
}

I’m sure this isn’t complete. Can you help me out?

0 Answers
Related